private void updateSelectionArea() { float x1 = (float) this.currentSelectionAreaStart.getX(); float y1 = (float) this.currentSelectionAreaStart.getY(); float x2 = (float) this.currentSelectionAreaEnd.getX(); float y2 = (float) this.currentSelectionAreaEnd.getY(); selectionAreaBuffer.putFloat(x1); selectionAreaBuffer.putFloat(y1); selectionAreaBuffer.putFloat(x2); selectionAreaBuffer.putFloat(y1); selectionAreaBuffer.putFloat(x2); selectionAreaBuffer.putFloat(y2); selectionAreaBuffer.putFloat(x1); selectionAreaBuffer.putFloat(y2); }
/** * Sets the temporary pan progress for a given pan operation. * * @param key * The identifier of the event * @param distance * The actual distance when the event ended. */ public synchronized void finishPanProgress(Object key, UIPoint distance) { this.panProgresses.remove(key); setScreenCenter((int) (this.screenCenterX - distance.getX() / zoom), (int) (this.screenCenterY - distance.getY() / zoom)); }
public GOEventHandlerImplementation(UIPoint lastpoint) { last = toMapPosition(lastpoint); firerer.fireAction(new StartDrawingAction(last)); starty = lastpoint.getY(); }
private ShortPoint2D toMapPosition(UIPoint lastpoint) { return context.getPositionOnScreen((float) lastpoint.getX(), (float) lastpoint.getY()); }
private void drawTooltip(GLDrawContext gl) { if (!tooltipString.isEmpty()) { TextDrawer drawer = textDrawer.getTextDrawer(gl, EFontSize.NORMAL); drawer.drawString((int) mousePosition.getX(), (int) mousePosition.getY(), tooltipString); } }
/** * Sets the mouse position as a given point. * * @param current * The position. */ protected void setMousePosition(final UIPoint current) { if (this.position != null) { mouseMoved += Math.abs(current.getX() - this.position.getX()) + Math.abs(current.getY() - this.position.getY()); } this.position = current; if (getPhase() == PHASE_MODAL) { fireModalDataRefreshed(); } } }
@Override public boolean containsPoint(UIPoint position) { float width = uiBase.getPosition().getWidth(); float uicenter = layoutProperties.miniMap.RIGHT_DECORATION_LEFT * width; return position.getX() < Math.max(uicenter, getMinimapOffset(position.getY()) + uicenter); }
@Override public void eventDataChanged(GOEvent event) { UIPoint pos = ((GODrawEvent) event).getDrawPosition(); ShortPoint2D cur = toMapPosition(pos); firerer.fireAction(new DrawLineAction(last, cur, pos.getY() - starty)); last = cur; } }
private synchronized void doPanStep() { if (this.getPhase() == PHASE_MODAL) { this.distance = new UIPoint(this.distance.getX() + dx, this.distance.getY() + dy); fireModalDataRefreshed(); } }
/** * Recalculates the x and y position of the screen by the current pan values. */ private void recalculateScreen() { float x = this.screenCenterX; float y = this.screenCenterY; int xoffset = 0; int yoffset = 0; for (UIPoint p : this.panProgresses.values()) { xoffset += p.getX() / zoom; yoffset += p.getY() / zoom; } setScreen(x - xoffset, y - yoffset, this.screen.getWidth(), this.screen.getHeight()); this.screenCenterX = this.screen.getCenterX() + xoffset; this.screenCenterY = this.screen.getCenterY() + yoffset; }
@Override public String getDescriptionFor(UIPoint position) { float relativex = (float) position.getX() / this.uiBase.getPosition().getWidth(); float relativey = (float) position.getY() / this.uiBase.getPosition().getHeight(); return uiBase.getDescription(relativex, relativey); }
private Action handleCommandOnMap(GOCommandEvent commandEvent, UIPoint position) { float x = (float) position.getX(); float y = (float) position.getY(); ShortPoint2D onMap = this.context.getPositionOnScreen(x, y); if (this.context.checkMapCoordinates(onMap.x, onMap.y)) { Action action; if (commandEvent.isSelecting()) { action = handleSelectCommand(onMap); } else { action = new PointAction(EActionType.MOVE_TO, onMap); } return action; } return null; }
private Action getActionForDraw(GODrawEvent event) { UIPoint position = event.getDrawPosition(); float width = this.uiBase.getPosition().getWidth(); float relativex = (float) position.getX() / width; float height = this.uiBase.getPosition().getHeight(); float relativey = (float) position.getY() / height; return getForMinimap(relativex, relativey, true); }
@Override public Action getActionFor(UIPoint position, boolean selecting) { float relativex = (float) position.getX() / this.uiBase.getPosition().getWidth(); float relativey = (float) position.getY() / this.uiBase.getPosition().getHeight(); Action action; if (minimap != null && relativey > layoutProperties.MAIN_PANEL_TOP && getMinimapOffset(position.getY()) < position.getX()) { action = getForMinimap(relativex, relativey, selecting); startMapPosition = null; // to prevent it from jumping back. } else { action = uiBase.getAction(relativex, relativey); } if (action != null && action.getActionType() == EActionType.CHANGE_PANEL) { mainPanel.setContent(((ChangePanelAction) action).getContent()); return null; } else { return action; } }