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)); }
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); }
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; }
/** * This is called whenever the mouse pointer position changed. Used for tooltips. * * @param position * The new mouse position. */ private void changeMousePosition(UIPoint position) { mousePosition = position; if (controls.containsPoint(position)) { tooltipString = controls.getDescriptionFor(position); } else { float x = (float) position.getX(); float y = (float) position.getY(); ShortPoint2D onMap = this.context.getPositionOnScreen(x, y); tooltipString = controls.getMapTooltip(onMap); } if (tooltipString == null) { tooltipString = ""; } }
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; } }
/** * Sets the size of the screen without the zoom level applied. * When called for zooming, screen at pointer stands still. * * @param newWidth * The width. * @param newHeight * The height. */ public void setSize(float newWidth, float newHeight) { if (newHeight / zoom > mapHeight + TOPBORDER) { zoom = newHeight / (mapHeight + TOPBORDER); } float x = screen.getCenterX(); float y = screen.getCenterY(); if (pointer != null) { float w = screen.getWidth(); float h = screen.getHeight(); float px = (float) pointer.getX(); float py = (float) pointer.getY(); x -= w / 2 - px / oldZoom + px / zoom - w / 2 * oldZoom / zoom; y -= h / 2 - py / oldZoom + py / zoom - h / 2 * oldZoom / zoom; screenCenterX = x; screenCenterY = y; } setScreen(x, y, newWidth / zoom, newHeight / zoom); }