You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/06/05 16:55:08 UTC
svn commit: r782033 - in /incubator/pivot/trunk: demos/src/pivot/demos/dnd/
demos/src/pivot/demos/rss/ wtk/src/pivot/wtk/content/
Author: gbrown
Date: Fri Jun 5 14:55:08 2009
New Revision: 782033
URL: http://svn.apache.org/viewvc?rev=782033&view=rev
Log:
Clean up content renderer code: don't bother to check for instanceof Color or Font, since it is valid for a renderer to assume that such types will be provided by a given skin (renderers and skins can be considered loosely coupled, not completely independent).
Modified:
incubator/pivot/trunk/demos/src/pivot/demos/dnd/FileCellRenderer.java
incubator/pivot/trunk/demos/src/pivot/demos/rss/RSSFeedDemo.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/ButtonDataRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/ListViewItemRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuBarItemDataRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuItemDataRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/SpinnerItemRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java
incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeRenderer.java
Modified: incubator/pivot/trunk/demos/src/pivot/demos/dnd/FileCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/pivot/demos/dnd/FileCellRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/pivot/demos/dnd/FileCellRenderer.java (original)
+++ incubator/pivot/trunk/demos/src/pivot/demos/dnd/FileCellRenderer.java Fri Jun 5 14:55:08 2009
@@ -40,34 +40,6 @@
public void render(Object value, TableView tableView, TableView.Column column,
boolean rowSelected, boolean rowHighlighted, boolean rowDisabled) {
- // Update the styles
- Object font = tableView.getStyles().get("font");
-
- if (font instanceof Font) {
- getStyles().put("font", font);
- }
-
- Object color = null;
-
- if (tableView.isEnabled() && !rowDisabled) {
- if (rowSelected) {
- if (tableView.isFocused()) {
- color = tableView.getStyles().get("selectionColor");
- } else {
- color = tableView.getStyles().get("inactiveSelectionColor");
- }
- } else {
- color = tableView.getStyles().get("color");
- }
- } else {
- color = tableView.getStyles().get("disabledColor");
- }
-
- if (color instanceof Color) {
- getStyles().put("color", color);
- }
-
- // Update the data
if (value != null) {
File file = (File)value;
String columnName = column.getName();
@@ -96,5 +68,25 @@
setText(text);
}
+
+ Font font = (Font)tableView.getStyles().get("font");
+ getStyles().put("font", font);
+
+ Color color;
+ if (tableView.isEnabled() && !rowDisabled) {
+ if (rowSelected) {
+ if (tableView.isFocused()) {
+ color = (Color)tableView.getStyles().get("selectionColor");
+ } else {
+ color = (Color)tableView.getStyles().get("inactiveSelectionColor");
+ }
+ } else {
+ color = (Color)tableView.getStyles().get("color");
+ }
+ } else {
+ color = (Color)tableView.getStyles().get("disabledColor");
+ }
+
+ getStyles().put("color", color);
}
}
Modified: incubator/pivot/trunk/demos/src/pivot/demos/rss/RSSFeedDemo.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/demos/src/pivot/demos/rss/RSSFeedDemo.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/demos/src/pivot/demos/rss/RSSFeedDemo.java (original)
+++ incubator/pivot/trunk/demos/src/pivot/demos/rss/RSSFeedDemo.java Fri Jun 5 14:55:08 2009
@@ -136,37 +136,6 @@
public void render(Object item, ListView listView, boolean selected,
boolean checked, boolean highlighted, boolean disabled) {
- // Render styles
- Font labelFont = (Font)listView.getStyles().get("font");
- Font largeFont = labelFont.deriveFont(Font.BOLD, 14);
- titleLabel.getStyles().put("font", largeFont);
- categoriesLabel.getStyles().put("font", labelFont);
- submitterLabel.getStyles().put("font", labelFont);
-
- Color color = null;
- if (listView.isEnabled() && !disabled) {
- if (selected) {
- if (listView.isFocused()) {
- color = (Color)listView.getStyles().get("selectionColor");
- } else {
- color = (Color)listView.getStyles().get("inactiveSelectionColor");
- }
- } else {
- color = (Color)listView.getStyles().get("color");
- }
- } else {
- color = (Color)listView.getStyles().get("disabledColor");
- }
-
- if (color instanceof Color) {
- titleLabel.getStyles().put("color", color);
- categoriesHeadingLabel.getStyles().put("color", color);
- categoriesLabel.getStyles().put("color", color);
- submitterHeadingLabel.getStyles().put("color", color);
- submitterLabel.getStyles().put("color", color);
- }
-
- // Render data
if (item != null) {
Element itemElement = (Element)item;
@@ -196,6 +165,35 @@
System.err.println(exception);
}
}
+
+ Font font = (Font)listView.getStyles().get("font");
+ Font largeFont = font.deriveFont(Font.BOLD, 14);
+ titleLabel.getStyles().put("font", largeFont);
+ categoriesLabel.getStyles().put("font", font);
+ submitterLabel.getStyles().put("font", font);
+
+ Color color;
+ if (listView.isEnabled() && !disabled) {
+ if (selected) {
+ if (listView.isFocused()) {
+ color = (Color)listView.getStyles().get("selectionColor");
+ } else {
+ color = (Color)listView.getStyles().get("inactiveSelectionColor");
+ }
+ } else {
+ color = (Color)listView.getStyles().get("color");
+ }
+ } else {
+ color = (Color)listView.getStyles().get("disabledColor");
+ }
+
+ if (color instanceof Color) {
+ titleLabel.getStyles().put("color", color);
+ categoriesHeadingLabel.getStyles().put("color", color);
+ categoriesLabel.getStyles().put("color", color);
+ submitterHeadingLabel.getStyles().put("color", color);
+ submitterLabel.getStyles().put("color", color);
+ }
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/ButtonDataRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/ButtonDataRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/ButtonDataRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/ButtonDataRenderer.java Fri Jun 5 14:55:08 2009
@@ -20,7 +20,6 @@
import java.awt.Font;
import pivot.wtk.Button;
-import pivot.wtk.Component;
import pivot.wtk.FlowPane;
import pivot.wtk.HorizontalAlignment;
import pivot.wtk.VerticalAlignment;
@@ -72,7 +71,7 @@
}
}
- // Show/hide the image view
+ // Update the image view
if (icon == null) {
imageView.setDisplayable(false);
} else {
@@ -82,28 +81,25 @@
imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);
}
- // Show/hide the label
+ // Update the label
+ label.setText(text);
+
if (text == null) {
label.setDisplayable(false);
} else {
label.setDisplayable(true);
- label.setText(text);
- // Update the label styles
- Component.StyleDictionary labelStyles = label.getStyles();
+ Font font = (Font)button.getStyles().get("font");
+ label.getStyles().put("font", font);
- Object labelFont = button.getStyles().get("font");
- if (labelFont instanceof Font) {
- labelStyles.put("font", labelFont);
+ Color color;
+ if (button.isEnabled()) {
+ color = (Color)button.getStyles().get("color");
+ } else {
+ color = (Color)button.getStyles().get("disabledColor");
}
- Object color = button.isEnabled() ?
- button.getStyles().get("color") :
- button.getStyles().get("disabledColor");
-
- if (color instanceof Color) {
- labelStyles.put("color", color);
- }
+ label.getStyles().put("color", color);
}
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/ListViewItemRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/ListViewItemRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/ListViewItemRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/ListViewItemRenderer.java Fri Jun 5 14:55:08 2009
@@ -20,7 +20,6 @@
import java.awt.Font;
import pivot.wtk.Bounds;
-import pivot.wtk.Component;
import pivot.wtk.FlowPane;
import pivot.wtk.HorizontalAlignment;
import pivot.wtk.ImageView;
@@ -94,38 +93,27 @@
protected void renderStyles(ListView listView, boolean selected,
boolean highlighted, boolean disabled) {
- Component.StyleDictionary listViewStyles = listView.getStyles();
+ imageView.getStyles().put("opacity", listView.isEnabled() ? 1.0f : 0.5f);
- Component.StyleDictionary imageViewStyles = imageView.getStyles();
- Component.StyleDictionary labelStyles = label.getStyles();
+ Font font = (Font)listView.getStyles().get("font");
+ label.getStyles().put("font", font);
- imageViewStyles.put("opacity", listView.isEnabled() ? 1.0f : 0.5f);
-
- if (label.getText() != null) {
- Object labelFont = listViewStyles.get("font");
- if (labelFont instanceof Font) {
- labelStyles.put("font", labelFont);
- }
-
- Object color = null;
- if (listView.isEnabled() && !disabled) {
- if (selected) {
- if (listView.isFocused()) {
- color = listViewStyles.get("selectionColor");
- } else {
- color = listViewStyles.get("inactiveSelectionColor");
- }
+ Color color;
+ if (listView.isEnabled() && !disabled) {
+ if (selected) {
+ if (listView.isFocused()) {
+ color = (Color)listView.getStyles().get("selectionColor");
} else {
- color = listViewStyles.get("color");
+ color = (Color)listView.getStyles().get("inactiveSelectionColor");
}
} else {
- color = listViewStyles.get("disabledColor");
- }
-
- if (color instanceof Color) {
- labelStyles.put("color", color);
+ color = (Color)listView.getStyles().get("color");
}
+ } else {
+ color = (Color)listView.getStyles().get("disabledColor");
}
+
+ label.getStyles().put("color", color);
}
public int getIconWidth() {
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuBarItemDataRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuBarItemDataRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuBarItemDataRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuBarItemDataRenderer.java Fri Jun 5 14:55:08 2009
@@ -86,31 +86,28 @@
}
// Update the label
+ label.setText(text);
+
if (text == null) {
label.setDisplayable(false);
} else {
label.setDisplayable(true);
- Object font = menuBar.getStyles().get("font");
- if (font instanceof Font) {
- label.getStyles().put("font", font);
- }
- Object color;
+ Font font = (Font)menuBar.getStyles().get("font");
+ label.getStyles().put("font", font);
+
+ Color color;
if (button.isEnabled()) {
if (highlighted) {
- color = menuBar.getStyles().get("highlightColor");
+ color = (Color)menuBar.getStyles().get("highlightColor");
} else {
- color = menuBar.getStyles().get("color");
+ color = (Color)menuBar.getStyles().get("color");
}
} else {
- color = menuBar.getStyles().get("disabledColor");
- }
-
- if (color instanceof Color) {
- label.getStyles().put("color", color);
+ color = (Color)menuBar.getStyles().get("disabledColor");
}
- label.setText(text);
+ label.getStyles().put("color", color);
}
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuItemDataRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuItemDataRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuItemDataRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/MenuItemDataRenderer.java Fri Jun 5 14:55:08 2009
@@ -102,30 +102,25 @@
imageView.getStyles().put("opacity", button.isEnabled() ? 1.0f : 0.5f);
// Update the labels
- Object font = menu.getStyles().get("font");
- if (font instanceof Font) {
- textLabel.getStyles().put("font", font);
- keyboardShortcutLabel.getStyles().put("font",
- ((Font)font).deriveFont(Font.ITALIC));
- }
+ textLabel.setText(text);
+
+ Font font = (Font)menu.getStyles().get("font");
+ textLabel.getStyles().put("font", font);
+ keyboardShortcutLabel.getStyles().put("font", font.deriveFont(Font.ITALIC));
- Object color;
+ Color color;
if (button.isEnabled()) {
if (highlighted) {
- color = menu.getStyles().get("highlightColor");
+ color = (Color)menu.getStyles().get("highlightColor");
} else {
- color = menu.getStyles().get("color");
+ color = (Color)menu.getStyles().get("color");
}
} else {
- color = menu.getStyles().get("disabledColor");
+ color = (Color)menu.getStyles().get("disabledColor");
}
- if (color instanceof Color) {
- textLabel.getStyles().put("color", color);
- keyboardShortcutLabel.getStyles().put("color", color);
- }
-
- textLabel.setText(text);
+ textLabel.getStyles().put("color", color);
+ keyboardShortcutLabel.getStyles().put("color", color);
boolean showKeyboardShortcuts = false;
if (menu.getStyles().containsKey("showKeyboardShortcuts")) {
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/SpinnerItemRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/SpinnerItemRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/SpinnerItemRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/SpinnerItemRenderer.java Fri Jun 5 14:55:08 2009
@@ -43,22 +43,16 @@
}
protected void renderStyles(Spinner spinner) {
- Object font = spinner.getStyles().get("font");
-
- if (font instanceof Font) {
- getStyles().put("font", font);
- }
-
- Object color = null;
+ Font font = (Font)spinner.getStyles().get("font");
+ getStyles().put("font", font);
+ Color color;
if (spinner.isEnabled()) {
- color = spinner.getStyles().get("color");
+ color = (Color)spinner.getStyles().get("color");
} else {
- color = spinner.getStyles().get("disabledColor");
+ color = (Color)spinner.getStyles().get("disabledColor");
}
- if (color instanceof Color) {
- getStyles().put("color", color);
- }
+ getStyles().put("color", color);
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TableViewCellRenderer.java Fri Jun 5 14:55:08 2009
@@ -68,30 +68,24 @@
Component.StyleDictionary tableViewStyles = tableView.getStyles();
Component.StyleDictionary styles = getStyles();
- Object font = tableViewStyles.get("font");
-
- if (font instanceof Font) {
- styles.put("font", font);
- }
-
- Object color = null;
+ Font font = (Font)tableViewStyles.get("font");
+ styles.put("font", font);
+ Color color;
if (tableView.isEnabled() && !rowDisabled) {
if (rowSelected) {
if (tableView.isFocused()) {
- color = tableViewStyles.get("selectionColor");
+ color = (Color)tableViewStyles.get("selectionColor");
} else {
- color = tableViewStyles.get("inactiveSelectionColor");
+ color = (Color)tableViewStyles.get("inactiveSelectionColor");
}
} else {
- color = tableViewStyles.get("color");
+ color = (Color)tableViewStyles.get("color");
}
} else {
- color = tableViewStyles.get("disabledColor");
+ color = (Color)tableViewStyles.get("disabledColor");
}
- if (color instanceof Color) {
- styles.put("color", color);
- }
+ styles.put("color", color);
}
}
Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeRenderer.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeRenderer.java?rev=782033&r1=782032&r2=782033&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeRenderer.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/content/TreeViewNodeRenderer.java Fri Jun 5 14:55:08 2009
@@ -20,7 +20,6 @@
import java.awt.Font;
import pivot.wtk.Bounds;
-import pivot.wtk.Component;
import pivot.wtk.FlowPane;
import pivot.wtk.HorizontalAlignment;
import pivot.wtk.ImageView;
@@ -100,39 +99,33 @@
imageView.getStyles().put("opacity",
(treeView.isEnabled() && !disabled) ? 1.0f : 0.5f);
- // Show/hide the label
+ // Update the label
+ label.setText(text);
+
if (text == null) {
label.setDisplayable(false);
} else {
label.setDisplayable(true);
- label.setText(text);
-
- // Update the label styles
- Component.StyleDictionary labelStyles = label.getStyles();
- Object labelFont = treeView.getStyles().get("font");
- if (labelFont instanceof Font) {
- labelStyles.put("font", labelFont);
- }
+ Font font = (Font)treeView.getStyles().get("font");
+ label.getStyles().put("font", font);
- Object color = null;
+ Color color;
if (treeView.isEnabled() && !disabled) {
if (selected) {
if (treeView.isFocused()) {
- color = treeView.getStyles().get("selectionColor");
+ color = (Color)treeView.getStyles().get("selectionColor");
} else {
- color = treeView.getStyles().get("inactiveSelectionColor");
+ color = (Color)treeView.getStyles().get("inactiveSelectionColor");
}
} else {
- color = treeView.getStyles().get("color");
+ color = (Color)treeView.getStyles().get("color");
}
} else {
- color = treeView.getStyles().get("disabledColor");
+ color = (Color)treeView.getStyles().get("disabledColor");
}
- if (color instanceof Color) {
- labelStyles.put("color", color);
- }
+ label.getStyles().put("color", color);
}
}