[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


> Have a look at the new screenshot (the old one I have deleted):

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

I hope so, that it can be integrated.

I have also tried at home, to integrate it.
Look at

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 I have in paint() before

if ((b.getModel().isArmed() && b.getModel().isPressed()) || b.isSelected())
     paintButtonPressed(g, b);


   paintButtonWallpaper(g, b);

written, so that my paint() in 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();


   if (b.isBorderPainted())
     SwingUtilities.calculateInnerArea(b, vr);
     vr = SwingUtilities.getLocalBounds(b);
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), b.getText(),
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 the following method:

 protected void paintButtonWallpaper(Graphics g, AbstractButton b)
   Rectangle area = new Rectangle();
   SwingUtilities.calculateInnerArea(b, area);

And in 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) {
       } else {
       g.setColor(new Color((int)red, (int) green, (int) blue));
       g.drawLine(x, y+(int)i, x+w-1, y+(int)i);

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, 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, which Theme was set.

Btw: You wanted to know my real name: it is Patrick.

And Btw2 at all:
I have a screenshot, how GNU Classpath looks with  Joao Victors icons.

Patrick  --- alias theuserbl

reply via email to

[Prev in Thread] Current Thread [Next in Thread]