Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to move an entire GPen object?
    primarykey
    data
    text
    <p>In Java using the acm.graphics GPen is there any way to move the entire drawn sequence of lines? I've read the manual thoroughly and I'm beginning to think it's not possible which brings me to my second question. Are there any other graphics objects in Java that work very similar to a pen that can also be moved. The reason I'm asking is because I've been working on a graphing program that allows mouse gestures to be used to pan around and zoom in and out. After building functionality for implicit functions I realized simply clearing the drawing board and redrawing everything is not going to cut it anymore so I really need to work on more efficient ways to handle intermediate changes of the graph without having to recalculate everything. For example with this or similar code:</p> <pre><code>GPen p = new GPen(); p.setLocation(100,100); //places the pen on the canvas at 100, 100 p.drawLine(-50,0); //draw a line left 50 pixels p.drawLine(50,-50); //draw a line right and up 50 pixels each p.drawLine(0,50); //draw a line down 50 pixels </code></pre> <p>This would result in a simple right triangle who's bottom right most point is at 100, 100 on a particular canvas. What I need to do is be able to move this same drawn sequence of lines relative to one another to another origin. What I hoping for is a class that has separate methods for <code>setLocation()</code> and <code>move()</code> where <code>setLocation()</code> controls pen position and <code>move()</code> would move the entire object around.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload