/** Negates the vector by negating its components. * * @return a reference to the called vector (NOT a copy) */ public synchronized IVector2 negate() { vector_.negate(); return this; }
public final static IVector2 getBasePosition(AbstractViewport vp, IVector2 dcPos, IVector2 position, IVector2 canvasSize, boolean invX, boolean invY) { IVector2 pos = vp.getPosition().copy().negate().add(vp.getObjectShift()).add(dcPos).add(position).divide(vp.getPaddedSize()).multiply(canvasSize); if (invX) pos.negateX().add(new Vector2Double(canvasSize.getXAsDouble(), 0)); if (invY) pos.negateY().add(new Vector2Double(0, canvasSize.getYAsDouble())); return pos; }
/** * Returns the clipping box. * @return clipping box */ public Rectangle getClippingBox() { Rectangle box = new Rectangle(); IVector2 pixSize = getPixelSize(); IVector2 boxStart = pixPosition_.copy().divide(pixSize).negate(); box.x = (int)Math.round(boxStart.getXAsDouble()); box.y = (int)Math.round(boxStart.getYAsDouble()); IVector2 boxSize = areaSize_.copy().divide(pixSize); box.width = (int) Math.ceil(boxSize.getXAsDouble()); box.height = (int) Math.ceil(boxSize.getYAsDouble()); return box; }
public void run() { areaSize_ = new Vector2Double(areaSize); setSize(areaSize.copy()); if (preserveAR_) { setPosition(paddedSize_.copy().subtract(areaSize_).multiply(0.5).negate()); } } });
public void componentResized(ComponentEvent e) { if ((canvas_.getWidth() == 0) || (canvas_.getHeight() == 0)) return; IVector2 oldPaddedSize = paddedSize_.copy(); setSize(size_); setPosition(paddedSize_.copy().subtract(oldPaddedSize).multiply(0.5).negate().add(position_)); }