[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OT: and now oceanButtonRect()
From: |
theUser BL |
Subject: |
Re: OT: and now oceanButtonRect() |
Date: |
Wed, 16 Nov 2005 13:36:29 +0000 |
Hi!
> Have a look at the new screenshot (the old one I have deleted):
> http://user.web-gear.com/theuserbl/screeny2.png
This looks indeed nice. I would happily integrate you code into
Classpath, if the methods could take the parameters that I mentioned in
my previous mail
ocenMenuRect() HAVE the same look and colors (pixel for pixel) like Suns
Java.
As I have said in my mail, ocenButtonRect() is only approximated like that
what Sun do. The reason is, that this what I have done is easier to create.
But as you have seen in screeny2.png, Suns color gradient and my color
cradient differs only a bit. And so I think, it is at the moment better then
nothing.
To the differences:
If you paint the colors of Suns button which comes from the top to the
button in a graphic, to see the mathamatical graphic, where at the button of
the coordinate system is the value 255 and at the top 0, then you would
something see like a "V" where the left line (which is the top part of the
button) is smaller.
To say it in short words: I have created here straight lines. So that from
the top of the button to the white part it comes continual the same
value-difference higher and after the white part the same value-different
lower.
But Suns button is only NEARLY like a "V". On the ends, the lines drift a
little bit outside. So that it two parabolas are. And the additional problem
is, that it is in bigger buttons a little bit bigger cutting of the
parabola.
My implementation in contrast have with every botton size the same cutting
of the line in the middle. So that the colors at the end of the buttons, are
on every button size the same.
Sorry, that I have at the moment no picture of it, what I mean. I have it at
home, but now I am again in the internetcafé.
I will see, if I can make my color-gradient of the button to become nearer
to Suns one.
and if Mark gives his ok, regarding copyright
assignmen. I don't know, if your contribution can go in without this
paperwork.
I hope so, that it can be integrated.
I have also tried at home, to integrate it.
Look at
http://user.web-gear.com/theuserbl/screeny3.png
This is how GNU Classpath looks on my home-computer. :-)
The only problem is, that the menu-buttons becomes also the Ocean look (in
Java 1.5 not) and the toggle button are still by the old look (in Java 1.5
it have the Ocean look).
Here what I have done to become this on the screenshot:
In BasicButtonUI.java I have in paint() before
if ((b.getModel().isArmed() && b.getModel().isPressed()) ||
b.isSelected())
paintButtonPressed(g, b);
comes,
paintButtonWallpaper(g, b);
written, so that my paint() in BasicButtonUI.java looks like
public void paint(Graphics g, JComponent c)
{ AbstractButton b = (AbstractButton) c;
Rectangle tr = new Rectangle();
Rectangle ir = new Rectangle();
Rectangle vr = new Rectangle();
Font f = c.getFont();
g.setFont(f);
if (b.isBorderPainted())
SwingUtilities.calculateInnerArea(b, vr);
else
vr = SwingUtilities.getLocalBounds(b);
String text = SwingUtilities.layoutCompoundLabel(c,
g.getFontMetrics(f),
b.getText(),
currentIcon(b),
b.getVerticalAlignment(),
b.getHorizontalAlignment(),
b.getVerticalTextPosition(),
b.getHorizontalTextPosition(),
vr, ir, tr,
b.getIconTextGap()
+ defaultTextShiftOffset);
paintButtonWallpaper(g, b);
if ((b.getModel().isArmed() && b.getModel().isPressed()) ||
b.isSelected())
paintButtonPressed(g, b);
paintIcon(g, c, ir);
if (text != null)
paintText(g, b, tr, text);
if (b.isFocusOwner() && b.isFocusPainted())
paintFocus(g, b, vr, tr, ir);
}
Additional I have added in BasicButtonUI.java the following method:
protected void paintButtonWallpaper(Graphics g, AbstractButton b)
{
Rectangle area = new Rectangle();
SwingUtilities.calculateInnerArea(b, area);
}
And in MetalButtonUI.java I have added:
protected void paintButtonWallpaper(Graphics g, AbstractButton b) {
Rectangle area = b.getVisibleRect();
int x=area.x, y=area.y, w=area.width, h=area.height;
double i;
double red, green, blue;
Color savedColor = g.getColor();
for (i=0; i<=h-1; i++) {
if (i<=h/3) {
red=0xdd+i/(h/3)*(0xff-0xdd);
green=0xe8+i/(h/3)*(0xff-0xe8);
blue=0xf3+i/(h/3)*(0xff-0xf3);
} else {
red=0xff-(i-(h/3))/(h*2/3)*(0xff-0xb9);
green=0xff-(i-(h/3))/(h*2/3)*(0xff-0xcf);
blue=0xff-(i-(h/3))/(h*2/3)*(0xff-0xe5);
}
g.setColor(new Color((int)red, (int) green, (int) blue));
g.drawLine(x, y+(int)i, x+w-1, y+(int)i);
}
g.setColor(savedColor);
}
Thats it.
The problem is only, that this have also effect to the Steel Theme, which
have then the same buttons like ocean.
For this I wanted in the MetalButtonUI.java, that paintButtonWallpaper()
looks something like
protected void paintButtonWallpaper(Graphics g, AbstractButton b) { if
(theme="Ocean")
{
[...]
}
}
or something like this. But I don't know how to ask in MetalButtonUI.java,
which Theme was set.
Btw: You wanted to know my real name: it is Patrick.
And Btw2 at all:
Under http://user.web-gear.com/theuserbl/screeny4.png
I have a screenshot, how GNU Classpath looks with Joao Victors icons.
Greatings
Patrick --- alias theuserbl