UDIG Developer Guide : Draw Command Example
This page last changed on Apr 13, 2005 by jgarnett.
DeleteFeatureCommand.java /** * Sets the ViewportGraphics object translate its 0,0 coordinate by -x,-y. * IE. shapes are drawn down and right if x,y are both positive. * * @author jeichar * @since 0.3 */ public class TranslateCommand extends AbstractDrawCommand implements IMapTransformCommand, IPreMapDrawCommand { private Point offset; /** * Construct <code>TranslateCommand</code>. * * @param offset The amount of offset */ public TranslateCommand(Point offset){ this.offset=offset; } /** * Construct <code>TranslateCommand</code>. * * @param x The amount of offset in the x-direction * @param y The amount of offset in the y-direction */ public TranslateCommand(int x, int y){ this.offset=new Point(x,y); } /** * @see net.refractions.udig.project.internal.command.Command#run() */ public void run() throws Exception { if(offset.x>0){ graphics.clearRect(0,0,offset.x,display.getHeight()); }else{ graphics.clearRect(display.getWidth(),0,-offset.x,display.getHeight()); } if(offset.y>0){ graphics.clearRect(0,0,display.getWidth(), offset.y); }else{ graphics.clearRect(0,display.getHeight(),display.getWidth(),-offset.y); } graphics.translate(offset); } /** * @see net.refractions.udig.project.internal.command.Command#copy() */ public Command copy() { return new TranslateCommand(offset); } /** * Sets the amount the command will translate during the next paint phase * * @param x x-translation * @param y y-translation */ public void setTranslation( int x, int y ) { offset.x=x; offset.y=y; } /** * Sets the amount the command will translate during the next paint phase * * @param offset The amount of translation */ public void setTranslation(Point offset ){ this.offset=offset; } /** * @see net.refractions.udig.project.command.Command#getName() */ public String getName() { return Policy.bind("TranslateCommand.translateDisplayArea"); //$NON-NLS-1$ } } |
![]() |
Document generated by Confluence on Nov 19, 2005 20:03 |