001package jmri.jmrit.display.controlPanelEditor.shape; 002 003import java.awt.Shape; 004import java.awt.event.ActionEvent; 005import java.awt.geom.Ellipse2D; 006import javax.swing.JPopupMenu; 007import jmri.jmrit.display.Editor; 008import jmri.jmrit.display.Positionable; 009 010/** 011 * PositionableCircle PositionableShapes. 012 * 013 * @author Pete Cressman Copyright (c) 2012 014 */ 015public class PositionableCircle extends PositionableShape { 016 017 public PositionableCircle(Editor editor) { 018 super(editor); 019 } 020 021 public PositionableCircle(Editor editor, Shape shape) { 022 super(editor, shape); 023 } 024 025 @Override 026 public void setHeight(int h) { 027 super.setHeight(h); 028 _width = _height; 029 } 030 031 @Override 032 protected Shape makeShape() { 033 return new Ellipse2D.Double(0, 0, _width, _width); 034 } 035 036 @Override 037 public Positionable deepClone() { 038 PositionableCircle pos = new PositionableCircle(_editor); 039 return finishClone(pos); 040 } 041 042 @Override 043 protected Positionable finishClone(PositionableShape pos) { 044 pos._width = _width; 045 pos._height = _height; 046 return super.finishClone(pos); 047 } 048 049 @Override 050 public boolean setEditItemMenu(JPopupMenu popup) { 051 String txt = Bundle.getMessage("editShape", Bundle.getMessage("Circle")); 052 popup.add(new javax.swing.AbstractAction(txt) { 053 @Override 054 public void actionPerformed(ActionEvent e) { 055 makeEditFrame(false); 056 } 057 }); 058 return true; 059 } 060 061 @Override 062 protected DrawFrame makeEditFrame(boolean create) { 063 _editFrame = new DrawCircle("editShape", "Circle", this, getEditor(), create); 064 _editFrame.setDisplayParams(this); 065 return _editFrame; 066 } 067 068}