@Override public PointAction getSelectAction(ShortPoint2D position) { return new PointAction(EActionType.SET_WORK_AREA, position); } });
private Action handleSelectCommand(ShortPoint2D onMap) { long currentTime = System.currentTimeMillis(); if (currentTime - lastSelectPointTime < DOUBLE_CLICK_TIME && onMap.equals(lastSelectPointPos)) { lastSelectPointTime = 0; return new PointAction(EActionType.SELECT_POINT_TYPE, onMap); } else { lastSelectPointTime = currentTime; lastSelectPointPos = onMap; return new PointAction(EActionType.SELECT_POINT, onMap); } }
/** * Gets the action for a click on the minimap. * * @param relativex * The position on the minimap. * @param relativey * The position on the minimap. * @param selecting * <code>true</code> if it was a selection click and the view should move there. * @return the action for that point or <code>null</code> for no action. */ private Action getForMinimap(float relativex, float relativey, boolean selecting) { float minimapx = (relativex - layoutProperties.miniMap.MAP_LEFT) / layoutProperties.miniMap.MAP_WIDTH; float minimapy = ((relativey - layoutProperties.MAIN_PANEL_TOP) / (1 - layoutProperties.MAIN_PANEL_TOP) - layoutProperties.miniMap.MAP_BOTTOM) / layoutProperties.miniMap.MAP_HEIGHT; ShortPoint2D clickPosition = minimap.getClickPositionIfOnMap(minimapx, minimapy); if (clickPosition != null) { if (selecting) { return new PointAction(EActionType.PAN_TO, clickPosition); } else { return new PointAction(EActionType.MOVE_TO, clickPosition); } } else { return null; } }
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; }