Author: alevkovsky
Date: 2008-11-19 07:50:36 -0500 (Wed, 19 Nov 2008)
New Revision: 11231
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java
Log:
Editor: adjust icons drawing
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java 2008-11-19
10:07:23 UTC (rev 11230)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorAdvancedThemeIcons.java 2008-11-19
12:50:36 UTC (rev 11231)
@@ -64,10 +64,10 @@
public void paint(ResourceContext context, Graphics2D graphics) {
Object[] stored = (Object[]) restoreData(context);
if (stored != null) {
- BufferedImage block1 = paintMainBlock(stored, false);
+ BufferedImage block1 = paintMainBlock(stored, false, false);
BufferedImage separator = paintSeparatorBlock(stored);
- BufferedImage block2 = paintMainBlock(stored, true);
- BufferedImage block3 = paintMainBlock(stored, true);
+ BufferedImage block2 = paintMainBlock(stored, true, false);
+ BufferedImage block3 = paintMainBlock(stored, true, true);
BufferedImage firstTriangle1 = paintFirstTriangleBlock(stored, false);
BufferedImage firstTriangle2 = paintFirstTriangleBlock(stored, true);
@@ -78,6 +78,7 @@
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
+
graphics.drawImage(block1, 0, 0, 22, 22, null);
graphics.drawImage(separator, 22, 0, 5, 22, null);
graphics.drawImage(block2, 0, 22, 22, 22, null);
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java 2008-11-19
10:07:23 UTC (rev 11230)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorIcons.java 2008-11-19
12:50:36 UTC (rev 11231)
@@ -26,6 +26,7 @@
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.RenderingHints;
+import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.Date;
@@ -51,7 +52,7 @@
private final String PANEL_BORDER_COLOR = "panelBorderColor";
private final String GENERAL_TEXT_COLOR = "generalTextColor";
- private final int SUB_BORDER_TRANSPARENCY = 100;
+ private final int SUB_BORDER_TRANSPARENCY = 150;
public EditorIcons() {
super();
@@ -105,7 +106,7 @@
}
- protected BufferedImage paintMainBlock(Object[] colors, boolean selected) {
+ protected BufferedImage paintMainBlock(Object[] colors, boolean selected, boolean
withoutSubBorders) {
int w = 22;
int h = 22;
@@ -128,11 +129,7 @@
} else {
contentColor = additionalBackgroundColor;
}
- Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
- Color.white);
- g2d.setPaint(gradient1);
- Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
- g2d.fill(border);
+ fillBodyWithGradient(g2d, w, h, contentColor);
// Draw Border
g2d.setColor(panelBorderColor);
@@ -140,11 +137,15 @@
g2d.drawLine(0, h - 1, w, h - 1);
// Draw subBorder
- g2d.setColor(subBorderColorWithAlpha);
- g2d.drawLine(0, 1, 0, h - 2);
- g2d.drawLine(0, 1, w - 1, 1);
- g2d.drawLine(w - 1, 1, w - 1, h - 2);
- g2d.drawLine(0, h - 2, w - 1, h - 2);
+ Color subBorderColorWithAlpha2 = new Color(contentColor.getRed(),
contentColor.getGreen(), contentColor.getBlue(), SUB_BORDER_TRANSPARENCY);
+ if(!withoutSubBorders){
+ g2d.setColor(subBorderColorWithAlpha);
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(0, 1, w - 1, 1);
+ g2d.setColor(subBorderColorWithAlpha2);
+ g2d.drawLine(0, h - 2, w - 1, h - 2);
+ g2d.drawLine(w-1, 1, w-1, h - 2);
+ }
g2d.dispose();
@@ -177,8 +178,7 @@
return image;
}
- protected BufferedImage paintFirstTriangleBlock(Object[] colors,
- boolean selected) {
+ protected BufferedImage paintFirstTriangleBlock(Object[] colors, boolean selected) {
int w = 11;
int h = 22;
@@ -194,19 +194,18 @@
Color generalTextColor = (Color) colors[3];
Color subBorderColorWithAlpha = new Color(255, 255, 255,
SUB_BORDER_TRANSPARENCY);
+
// Draw body
Color contentColor;
if (selected) {
contentColor = selectControlColor;
+
} else {
contentColor = additionalBackgroundColor;
}
- Paint gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
- Color.white);
- g2d.setPaint(gradient1);
- Rectangle2D border = new Rectangle2D.Double(0, 1, w, h - 1);
- g2d.fill(border);
+ Color subBorderColorWithAlpha2 = new Color(contentColor.getRed(),
contentColor.getGreen(), contentColor.getBlue(), SUB_BORDER_TRANSPARENCY);
+ fillBodyWithGradient(g2d, w, h, contentColor);
// Draw Border
g2d.setColor(panelBorderColor);
@@ -215,10 +214,14 @@
// Draw body
g2d.setColor(subBorderColorWithAlpha);
- g2d.drawLine(0, 1, 0, h - 2);
- g2d.drawLine(0, 1, w - 1, 1);
- g2d.drawLine(w - 1, 1, w - 1, h - 2);
+
+ g2d.drawLine(0, 1, 0, h - 2);
+ g2d.drawLine(0, 1, w - 1, 1);
+
+ g2d.setColor(subBorderColorWithAlpha2);
+ g2d.drawLine(w - 1, 1, w - 1, h - 2);
g2d.drawLine(0, h - 2, w - 1, h - 2);
+
paintTriangle(g2d, 3, 10, generalTextColor, Color.WHITE, true);
@@ -241,8 +244,7 @@
}
- protected BufferedImage paintSecondTriangleBlock(Object[] colors,
- boolean selected) {
+ protected BufferedImage paintSecondTriangleBlock(Object[] colors, boolean selected) {
int w = 14;
int h = 22;
@@ -260,22 +262,15 @@
SUB_BORDER_TRANSPARENCY);
// Draw body
- Paint gradient1;
+
Color contentColor;
if (selected) {
contentColor = selectControlColor;
- gradient1 = new GradientPaint(w - 2, h - 2, contentColor, 2, 2,
- Color.white);
} else {
contentColor = additionalBackgroundColor;
- gradient1 = new GradientPaint(w, h - 1, contentColor, 0, 1,
- Color.white);
}
+ fillBodyWithGradient(g2d, w, h, contentColor);
- g2d.setPaint(gradient1);
- Rectangle2D border = new Rectangle2D.Double(1, 1, w - 1, h - 1);
- g2d.fill(border);
-
// Draw Border
g2d.setColor(panelBorderColor);
g2d.drawLine(0, 0, w, 0);
@@ -284,17 +279,50 @@
g2d.drawLine(w - 1, 0, w - 1, h);
// Draw subBorder
- g2d.setColor(subBorderColorWithAlpha);
- g2d.drawLine(1, 1, 1, h - 2);
- g2d.drawLine(1, 1, w - 2, 1);
- g2d.drawLine(w - 2, 1, w - 2, h - 2);
+ if(selected){
+ g2d.setColor(Color.white);
+ }else{
+ g2d.setColor(subBorderColorWithAlpha);
+ }
+ if(selected){
+ g2d.drawLine(1, 1, 1, h - 2);
+ g2d.drawLine(w - 2, 1, w - 2, h - 2);
+ }
+ g2d.drawLine(1, 1, w - 2, 1);
g2d.drawLine(1, h - 2, w - 2, h - 2);
paintTriangle(g2d, 4, 10, generalTextColor, Color.WHITE, true);
return image;
}
+
+ private void fillBodyWithGradient(Graphics2D g2d, int w, int h, Color color) {
+ Color halfColor = new Color(color.getRed(), color.getGreen(), color
+ .getBlue(), 90);
+ Color halfColor2 = new Color(color.getRed(), color.getGreen(), color
+ .getBlue(), 255);
+ Rectangle2D border = new Rectangle2D.Double(0, 0, w, h);
+ g2d.setColor(Color.WHITE);
+ g2d.fill(border);
+
+ g2d.setColor(halfColor);
+ border = new Rectangle2D.Double(0, 0, w, h * 0.4);
+ g2d.fill(border);
+
+ Point2D point2 = new Point2D.Double(w * 0.5, h * 0.4);
+ Point2D point3 = new Point2D.Double(w * 0.5, h);
+
+ border = new Rectangle2D.Double(0, h * 0.4, w, h);
+
+ Paint gradient = new GradientPaint(point2, halfColor2, point3,
+ halfColor);
+ g2d.setPaint(gradient);
+
+ g2d.fill(border);
+
+ }
+
private Graphics2D prepareImage(BufferedImage image) {
Graphics2D g2d = image.createGraphics();
Modified:
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java
===================================================================
---
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java 2008-11-19
10:07:23 UTC (rev 11230)
+++
trunk/sandbox/ui/editor/src/main/java/org/richfaces/renderkit/html/images/EditorSimpleThemeIcons.java 2008-11-19
12:50:36 UTC (rev 11231)
@@ -64,10 +64,10 @@
public void paint(ResourceContext context, Graphics2D graphics) {
Object[] stored = (Object[]) restoreData(context);
if (stored != null) {
- BufferedImage block1 = paintMainBlock(stored, false);
+ BufferedImage block1 = paintMainBlock(stored, false, false);
BufferedImage separator = paintSeparatorBlock(stored);
- BufferedImage block2 = paintMainBlock(stored, true);
- BufferedImage block3 = paintMainBlock(stored, true);
+ BufferedImage block2 = paintMainBlock(stored, true, false);
+ BufferedImage block3 = paintMainBlock(stored, true, true);
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);