I'm trying to make a custom GraphicalCompositeFigure in JHotDraw. I want it to basically be a figure which has an Ellipse background, with 3 text fields in the center. I've tried a lot of different things and can't get it to work. I want the size of the ellipse to be fixed. I'm trying to do this when I create a new Figure:
Code:public MyFigure() { this(new EllipseFigure()); } public MyFigure(Figure newPresentationFigure) { super(newPresentationFigure); } protected void initialize() { // start with an empty Composite removeAll(); // set the fonts used to print fields parameterFont = new Font("Helvetica", Font.PLAIN, 12); // create a new Model object associated with this View figure setMyClass(new MyClass("myMy")); // create a TextFigure responsible for the My name setMyNameFigure(new TextFigure() { public void setText(String newText) { super.setText(newText); getMyClass().setName(newText); update(); } public void drawBackground(Graphics g) { //do nothing, we don't want a background. } }); getMyNameFigure().setFont(new Font("Helvetica", Font.BOLD, 12)); getMyNameFigure().setText(getMyClass().getName()); // add the TextFigure to the Composite //GraphicalCompositeFigure nameFigure = new GraphicalCompositeFigure(); //nameFigure.add(getMyNameFigure()); //nameFigure.getLayouter().setInsets(new Insets(0, 4, 0, 0)); //add(nameFigure); super.initialize(); getLayouter().setInsets(new Insets(250,0,125,500)); //nameFigure.moveBy(300,125); getMyNameFigure().basicDisplayBox(center(), null); add(getMyNameFigure()); // displayBox(new Point(0,0), new Point(200,200)); //update(); }




Reply With Quote