|
Re: How can I create new geometrical shapes? [message #201134 is a reply to message #201104] |
Sat, 29 October 2005 21:07 |
venkataramana m Messages: 86 Registered: July 2009 |
Member |
|
|
Follow the steps below ...
1. Create a new class (say Triangle) as subclass of Shape.
2. Implement outlineShape and fillShape methods for your new class (Triange). Use the methods available with the Graphics parameter passed to those two methods.
Graphics has methods like ...
public abstract class Graphics
{
public final void drawArc(Rectangle r, int offset, int length)
public abstract void fillArc(int x, int y, int w, int h, int offset, int length)
public final void drawLine(Point p1, Point p2)
public final void drawOval(Rectangle r)
public final void fillOval(Rectangle r)
public abstract void drawPolygon(PointList points)
public abstract void fillPolygon(PointList points)
public final void drawRectangle(Rectangle r)
public final void fillRectangle(Rectangle r)
public abstract void drawText(String s, int x, int y)
...
}
Thats it. You should be get going with wonderful geometrical shapes close to your heart.
Thanks
Venkat
|
|
|
|
|
|
|
Re: How can I create new geometrical shapes? [message #201209 is a reply to message #201202] |
Mon, 31 October 2005 09:36 |
Eclipse User |
|
|
|
Originally posted by: ciulbecca.yahoo.it
In this part of code:..
[code/
class GraphElementEditpart ...implements NodeEditpart
{
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
connection) {
//return new ChopboxAnchor(getFigure()); /* TODO Change anchors */
return new WhereYouPlaceThereYouGetAnchor(getFigure(),
((GraphEdgeEditPart)connection).getGraphEdge().getSourceAnch orLocation());
}
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart
connection) {
//return new ChopboxAnchor(getFigure()); /* TODO Change anchors */
return new WhereYouPlaceThereYouGetAnchor(getFigure(),
((GraphEdgeEditPart)connection).getGraphEdge().getTargetAnch orLocation());
}
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
//return new ChopboxAnchor(getFigure()); /* TODO Change anchors */
return new WhereYouPlaceThereYouGetAnchor(getFigure(),
((CreateConnectionRequest)request).getLocation());
}
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
//return new ChopboxAnchor(getFigure()); /* TODO Change anchors */
return new WhereYouPlaceThereYouGetAnchor(getFigure(),
((CreateConnectionRequest)request).getLocation());
}
}
/]code
How must rename or which import i must do to not obtain error in this part:
"GraphElementEditpart ..."
"GraphEdgeEditPart"
?
Thanks
|
|
|
Powered by
FUDForum. Page generated in 0.03417 seconds