You are not logged in.

Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

1

Sunday, July 5th 2009, 11:24am

Rectangle2D.Float missing

Hello to all!

I need to use java.awt.geom.Rectangle2d.Float for my vector drawing program, but i can't find that class.
Is there any way to include it in reference?

Thanks,
Milan

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

2

Sunday, July 5th 2009, 12:45pm

Hi,
"Float" is a nested (or inner) class defined in Rectangle2D.
Nested classes should be supported from Jabaco 1.4.2 onwards.
Are you stil using the 1.4.0 version? Then an update should be your remedy.
But "Float" is invisible in the 1.4.2 project class reference tree. So, there might be some gap in Jabaco.

A workaround could be to invent your own sub-class of Rectangle2D:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
public static class Float extends Rectangle2D
    implements Serializable
  {
    public float x;
    public float y;
    public float width;
    public float height;
    private static final long serialVersionUID = 3798716824173675777L;

    public Float()
    {
    }

    public Float(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
    {
      setRect(paramFloat1, paramFloat2, paramFloat3, paramFloat4);
    }

    public double getX()
    {
      return this.x;
    }

    public double getY()
    {
      return this.y;
    }

    public double getWidth()
    {
      return this.width;
    }

    public double getHeight()
    {
      return this.height;
    }

    public boolean isEmpty()
    {
      return ((this.width <= 0.0F) || (this.height <= 0.0F));
    }

    public void setRect(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4)
    {
      this.x = paramFloat1;
      this.y = paramFloat2;
      this.width = paramFloat3;
      this.height = paramFloat4;
    }

    public void setRect(double paramDouble1, double paramDouble2, double paramDouble3, double paramDouble4)
    {
      this.x = (float)paramDouble1;
      this.y = (float)paramDouble2;
      this.width = (float)paramDouble3;
      this.height = (float)paramDouble4;
    }

    public void setRect(Rectangle2D paramRectangle2D)
    {
      this.x = (float)paramRectangle2D.getX();
      this.y = (float)paramRectangle2D.getY();
      this.width = (float)paramRectangle2D.getWidth();
      this.height = (float)paramRectangle2D.getHeight();
    }

    public int outcode(double paramDouble1, double paramDouble2)
    {
      int i = 0;
      if (this.width <= 0.0F)
        i |= 5;
      else if (paramDouble1 < this.x)
        i |= 1;
      else if (paramDouble1 > this.x + this.width) {
        i |= 4;
      }
      if (this.height <= 0.0F)
        i |= 10;
      else if (paramDouble2 < this.y)
        i |= 2;
      else if (paramDouble2 > this.y + this.height) {
        i |= 8;
      }
      return i;
    }

    public Rectangle2D getBounds2D()
    {
      return new Float(this.x, this.y, this.width, this.height);
    }

    public Rectangle2D createIntersection(Rectangle2D paramRectangle2D)
    {
      Object localObject;
      if (paramRectangle2D instanceof Float)
        localObject = new Float();
      else {
        localObject = new Rectangle2D.Double();
      }
      Rectangle2D.intersect(this, paramRectangle2D, (Rectangle2D)localObject);
      return ((Rectangle2D)localObject);
    }

    public Rectangle2D createUnion(Rectangle2D paramRectangle2D)
    {
      Object localObject;
      if (paramRectangle2D instanceof Float)
        localObject = new Float();
      else {
        localObject = new Rectangle2D.Double();
      }
      Rectangle2D.union(this, paramRectangle2D, (Rectangle2D)localObject);
      return ((Rectangle2D)localObject);
    }

    public String toString()
    {
      return super.getClass().getName() + "[x=" + this.x + ",y=" + this.y + ",w=" + this.width + ",h=" + this.height + "]";
    }
  }


I extracted this code from rt.jar using a java decompiler

Cheers!

A1880

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

3

Sunday, July 5th 2009, 1:53pm

Hi A1880,
Thanks for your response.
Installed Jabaco is 1.4.2, but there is no float or double instance of any geometrics figure.
This will be useful for runtime resizing and manipulating graphics drawings.
Like:

dim rct as java#awt#geom#Rectangle2D#Float=new java#awt#geom#Rectangle2D#Float(10,10,30,30)
dim grx as java#awtGraphics2D=cast(Picture1.GetGraphics,java#awt#Graphics2D)
grx.fill(rct)...

and Picture1.MouseMove event...

if rct.contains(x,y) then move, resize, etc..


Thanks again,
Milan

Manuel

Administrator

  • "Manuel" is male

Posts: 256

Date of registration: Jul 16th 2008

Location: Erlangen, Germany

Occupation: Software Developer

Hobbies: Jabaco, game theory, text-mining

  • Send private message

4

Sunday, July 5th 2009, 3:15pm

Quoted

Installed Jabaco is 1.4.2, but there is no float or double instance of any geometrics figure.
Sample for inner-classes:

Jabaco Source

1
Dim test As New java#awt#geom#Rectangle2D$Float

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

5

Sunday, July 5th 2009, 7:36pm

Good to know, how to access nested classes.

I am dreaming of a future Jabaco which will use simple periods "." rather than "#" and "$".

Cheers!

A1880

Manuel

Administrator

  • "Manuel" is male

Posts: 256

Date of registration: Jul 16th 2008

Location: Erlangen, Germany

Occupation: Software Developer

Hobbies: Jabaco, game theory, text-mining

  • Send private message

6

Sunday, July 5th 2009, 9:49pm

Quoted

I am dreaming of a future Jabaco which will use simple periods "." rather than "#" and "$".
Why?

birosys

Trainee

  • "birosys" is male
  • "birosys" started this thread

Posts: 48

Date of registration: Feb 9th 2009

Location: Mladenovac, Serbia

Occupation: Programming

Hobbies: Programming

  • Send private message

7

Sunday, July 5th 2009, 10:43pm

Thanks for help guys :D

Milan

A1880

Intermediate

  • "A1880" is male

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

8

Sunday, July 5th 2009, 11:35pm

Hi,
there are several reasons for the "." as unified separator:

1.) I always seem to get it wrong selecting the proper separator.
Maybe I have not properly understood the underlying concepts (namespaces vs. classes)
2.) All other programing languages familiar to me are using "."
3.) "#" and "$" are typically used for other purposes:
- c/c++ uses "#" to indicate meta commands like #include and #define
- "$" is often used to indicate variables
- "$" relates to strings in VB6
4.) I can't see any advantage for the developer to have different separators.
If the difference actually would have a meaning, one could define a nested class and a method or member variable with the same name.
That would be quite confusing and error prone. I tried it in Java, and it seems to be allowed (see example below).
It might be easier to implement for Jabaco, but ...

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class AClass {
	AClass() {
		B b = new B();
		int i = B;
		
		b = new AClass.B();
		i = this.B;
	}
	
	public class B extends AClass {
		
	}
	
	public int B;     //  allowed name clash between variable B and nested class B
}


Enough reasons?

Cheers

A1880

Manuel

Administrator

  • "Manuel" is male

Posts: 256

Date of registration: Jul 16th 2008

Location: Erlangen, Germany

Occupation: Software Developer

Hobbies: Jabaco, game theory, text-mining

  • Send private message

9

Monday, July 6th 2009, 9:17pm

Quoted

1.) I always seem to get it wrong selecting the proper separator.
2.) All other programing languages familiar to me are using "."
3.) "#" and "$" are typically used for other purposes
4.) I can't see any advantage for the developer to have different separators.
Ok - matter of habit. It's faster for the compiler to use another char to separate the namespace and it's difficult to change - but I'll think about your request...

swissmade

Beginner

  • "swissmade" is male

Posts: 46

Date of registration: Aug 4th 2011

Location: The Netherlands

Occupation: Old Fasion Programmer

Hobbies: Play Music with my Bass

  • Send private message

10

Sunday, August 14th 2011, 11:27am

Quoted

1.) I always seem to get it wrong selecting the proper separator.
2.) All other programing languages familiar to me are using "."
3.) "#" and "$" are typically used for other purposes
4.) I can't see any advantage for the developer to have different separators.
Ok - matter of habit. It's faster for the compiler to use another char to separate the namespace and it's difficult to change - but I'll think about your request...
Maybe some settings in Jabaco can help here and your choice which separator you like to use.
Cheers :rolleyes:

This post has been edited 1 times, last edit by "swissmade" (Aug 16th 2011, 8:14am)


Rate this thread
WoltLab Burning Board