Java 如何在像JHotDraw这样的矢量图形编辑器中获得画布大小(宽度和高度)

Java 如何在像JHotDraw这样的矢量图形编辑器中获得画布大小(宽度和高度),java,canvas,height,awt,width,Java,Canvas,Height,Awt,Width,首先,我想说我不太擅长编程 我试图在JHotDraw(一个矢量图形编辑器,也使用Java.awt)中实现一个新图形。我想得到画布的宽度和高度,因为我将在设置新图形的尺寸时使用它 在名为AttributeKeys.java的类中,我发现了以下属性: /** * The width of the canvas. The value of this attribute is a Double object. * This is a value between 1 and Do

首先,我想说我不太擅长编程

我试图在JHotDraw(一个矢量图形编辑器,也使用Java.awt)中实现一个新图形。我想得到画布的宽度和高度,因为我将在设置新图形的尺寸时使用它

在名为AttributeKeys.java的类中,我发现了以下属性:

   /**
     * The width of the canvas. The value of this attribute is a Double object.
     * This is a value between 1 and Double.MAX_VALUE. If the value is null, the
     * width is dynamically adapted to the content of the drawing.
     */
    public final static AttributeKey<Double> CANVAS_WIDTH = new AttributeKey<Double>("canvasWidth", Double.class, null, true, labels);
在我的figure类中,我尝试按如下方式打印画布尺寸:

    DefaultDrawing d = new DefaultDrawing();
    System.out.println(d.getCanvasSize());
并且输出为空

我不知道如何获得绘图页/画布的宽度和高度值。我该怎么做?

1)如果没有更多的a)咨询API,您将无法解决此问题,&b)显示a)。2) 我注意到它扩展了
JComponent
,这意味着它是基于Swing的(或者至少提供Swing功能)。这并不奇怪,因为Swing很久以前就取代了AWT。。。。3) 在返回本项目之前,您应该熟悉使用核心Java编写GUI。你吃的比你能吃的多得多,或者我们可以用勺子喂。1)如果没有更多的a)咨询API,你将无法解决这个问题,&b)显示a。2) 我注意到它扩展了
JComponent
,这意味着它是基于Swing的(或者至少提供Swing功能)。这并不奇怪,因为Swing很久以前就取代了AWT。。。。3) 在返回本项目之前,您应该熟悉使用核心Java编写GUI。你吃的比你能嚼的多得多,或者我们可以用勺子喂。
    DefaultDrawing d = new DefaultDrawing();
    System.out.println(d.getCanvasSize());