/** * Gets the shift of all objects. */ public IVector2 getObjectShift() { return new Vector2Double(objShiftX_, objShiftY_); }
public IVector2 copy() { return new Vector2Double(x_, y_); }
/** * Creates a new TiledLayer. */ public TiledLayer() { this(new Vector2Double(1.0), Color.WHITE, ""); }
/** * Get a vector for two doubles. * @param a The first value. * @param b The second value. * @return The vector (null if at least one of args is null). */ public static IVector2 getVector2(Double a, Double b) { IVector2 ret = null; if(a!=null && b!=null) ret = a.doubleValue()==0 && b.doubleValue()==0? ZERO: new Vector2Double(a.doubleValue(), b.doubleValue()); else if (a!=null || b !=null) ret = new Vector2Double(a == null? 0.0:a.doubleValue(), b == null? 0.0:b.doubleValue()); return ret; }
/** * Returns the size of the canvas as a vector. * @return size of the canvas in pixel */ public IVector2 getCanvasSize() { return new Vector2Double(canvas_.getWidth(), canvas_.getHeight()); }
/** * Create a vector2 from this and another vector. * @param sec The second vector. */ public IVector2 createVector2(IVector1 sec) { return new Vector2Double(this.getAsDouble(), sec.getAsDouble()); }
/** * Create a vector2 from this and another vector. * @param sec The second vector. */ public IVector2 createVector2(IVector1 sec) { return new Vector2Double(this.getAsLong(), sec.getAsLong()); }
/** * Create a vector2 from this and another vector. * @param sec The second vector. */ public IVector2 createVector2(IVector1 sec) { return new Vector2Double(this.getAsInteger(), sec.getAsInteger()); }
/** * Returns the size of the canvas as a vector. * @return size of the canvas in pixel */ public IVector2 getCanvasSize() { return new Vector2Double(canvas_.getWidth(), canvas_.getHeight()); }
/** * Initializes the members with default values. */ public AbstractVisual2D(Object position, Object rotation, Object size) { this.size = size!=null? size: new Vector2Double(1.0); this.rotation = rotation!=null? rotation: Vector3Double.ZERO.copy(); this.position = position!=null? position: Vector2Double.ZERO.copy(); }
public AbstractViewport3d(IPerspective perspective, IVector3 areasize, boolean isGrid, boolean shader, String camera, ISpaceController spaceController) { rendering = false; this.perspective = perspective; size_ = new Vector3Double(1.0); position_ = Vector3Double.ZERO.copy(); isGrid_ = isGrid; preserveAR_ = true; areaSize_ = areasize; paddedSize_ = new Vector2Double(1.0); drawObjects_ = new HashSet<Object>(); // objectList_ = new ArrayList<Object>(); listeners_ = new HashSet<Object>(); // zoomLimit_ = 20.0; this.shader = shader; this.camera = camera; this.spacecontroller = spaceController; }
public Text(Object position, Font baseFont, Color color, String text, int halign, int valign, int absFlags, IParsedExpression drawcondition) { super(Primitive.PRIMITIVE_TYPE_TEXT, position, Vector3Double.ZERO.copy(), new Vector2Double(1.0), absFlags, color, drawcondition); setHAlign(halign); setVAlign(valign); if (baseFont == null) baseFont = new Font(null); this.baseFont = baseFont; if (text == null) text = ""; this.text = text; }
/** * Creates a new TiledLayer. * * @param tileSize size of an individual tile * @param color the modulation color * @param texturePath resource path of the texture */ public TiledLayer(IVector2 tileSize, Object color, String texturePath) { super(Layer.LAYER_TYPE_TILED, color); this.tileSize_ = tileSize.copy(); //this.modColor_ = color==null? Color.WHITE: color; this.invTileSize_ = (new Vector2Double(1.0)).divide(tileSize_); this.texturePath_ = texturePath; //texture_ = 0; }
/** * The plan body. */ public void body() { double x_dest = Math.random(); double y_dest = Math.random(); Vector2Double dest = new Vector2Double(x_dest, y_dest); IGoal moveto = createGoal("achievemoveto"); moveto.getParameter("location").setValue(dest); // System.out.println("Created: "+dest+" "+this); dispatchSubgoalAndWait(moveto); // System.out.println("Reached: "+dest+" "+this); // getLogger().info("Reached point: "+dest); } }
/** * Returns the size of a pixel. * @retun size of a pixel */ public IVector2 getPixelSize() { Canvas canvas = canvas_; if (canvas == null) return Vector2Double.ZERO; return paddedSize_.copy().divide(new Vector2Double(canvas.getWidth(), canvas.getHeight())); }
/** * Sets the position of the viewport. */ public void setPosition(IVector2 pos) { position_ = pos; IVector2 pixSize = getPixelSize(); pixPosition_ = position_.copy().divide(pixSize); pixPosition_ = (new Vector2Double(new Vector2Int(pixPosition_))).multiply(pixSize); }
public void run() { areaSize_ = new Vector2Double(areaSize); setSize(areaSize.copy()); if (preserveAR_) { setPosition(paddedSize_.copy().subtract(areaSize_).multiply(0.5).negate()); } } });
public void mouseDragged(MouseEvent e) { if (lastDragPos != null) { IVector2 position = (new Vector2Double(e.getX(), e.getY())).multiply(getPixelSize()); IVector2 diff = position.copy().subtract(lastDragPos); if (getInvertX()) diff.negateX(); if (!getInvertY()) diff.negateY(); lastDragPos = position; setPosition(getPosition().copy().subtract(diff)); } }
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; }
/** Sets a new zoom factor * @param zoom new zoom factor */ public void setZoom(double zoom) { IVector2 newSize = viewport.getAreaSize().copy().divide(new Vector2Double(zoom)); IVector2 oldSize = viewport.getSize().copy(); IVector2 pos = viewport.getPosition(); viewport.setSize(newSize); pos.add(oldSize.subtract(newSize).multiply(0.5)); viewport.setPosition(pos); }