Пример #1
0
 @Override
 public void setMap(Map map) {
   this.map = map;
   setPreferredSize(map.getSize()); // Don't remove it.
   setSize(map.getSize()); // Don't remove it. use to SnapshotPanel
   map.addUndoableEditListener(undoManager);
   mapBounds = new Rectangle();
   mapBounds.setSize(map.getLogicalSize());
 }
Пример #2
0
 @Override
 public Point screenToMap(Point mousePoint) {
   Point p = new Point();
   p.x = mousePoint.x - bounds.x;
   p.y = mousePoint.y - bounds.y;
   return map.screenToMap(p);
 }
Пример #3
0
 @Override
 public Point mapToScreen(Point mapPoint) {
   Point p = map.mapToScreen(mapPoint);
   p.x += bounds.x;
   p.y += bounds.y;
   return p;
 }
Пример #4
0
  @Override
  public boolean equals(Object obj) {
    if (obj == null) {
      return false;
    }
    if (!(obj instanceof EditorView) || (!obj.getClass().equals(this.getClass()))) {
      return false;
    }

    AbstractEditorView other = (AbstractEditorView) obj;
    return map.equals(other.map);
  }
Пример #5
0
  protected void updateBounds() {
    Dimension mapSize = map.getSize();
    Dimension panelSize = getSize();

    bounds.x = (mapSize.width >= panelSize.width) ? 0 : (panelSize.width - mapSize.width) / 2;
    ;
    bounds.y = (mapSize.height >= panelSize.height) ? 0 : (panelSize.height - mapSize.height) / 2;

    bounds.width = mapSize.width;
    bounds.height = mapSize.height;

    repaint();
  }
Пример #6
0
  public AbstractEditorView(Map map) {
    setMap(map);

    selection = new EditorSelection();
    bounds = new Rectangle();
    Dimension d = map.getSize();
    bounds.width = d.width;
    bounds.height = d.height;

    initBufferImage();
    addComponentListener(resizeListener);

    //		setDoubleBuffered(true);
  }
Пример #7
0
 protected void drawCoordinate(Graphics2D g) {
   g.setColor(new Color(0, 0, 0)); // XXX read from preference file.
   map.drawCoordinate(0, 0, mapBounds, g);
 }
Пример #8
0
 protected void drawGrid(Graphics2D g) {
   g.setColor(new Color(0, 255, 255, 90)); // XXX read from preference file.
   map.drawGrid(0, 0, mapBounds, g);
 }
Пример #9
0
 protected void drawMap(Graphics2D g) {
   map.draw(0, 0, mapBounds, g);
 }
Пример #10
0
 private BufferedImage createImage() {
   Dimension d = map.getSize();
   return new BufferedImage(d.width + 1, d.height + 1, BufferedImage.TYPE_4BYTE_ABGR);
 }