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 * @author Pete Cressman Copyright (c) 2012
012 */
013public class PositionableEllipse extends PositionableRectangle {
014
015    public PositionableEllipse(Editor editor) {
016        super(editor);
017    }
018
019    public PositionableEllipse(Editor editor, Shape shape) {
020        super(editor, shape);
021    }
022
023    @Override
024    protected Shape makeShape() {
025        return new Ellipse2D.Double(0, 0, _width, _height);
026    }
027
028    @Override
029    public Positionable deepClone() {
030        PositionableEllipse pos = new PositionableEllipse(_editor);
031        return finishClone(pos);
032    }
033
034    /*    protected Positionable finishClone(PositionableShape pos) {
035        pos._width = _width;
036        pos._height = _height;
037        return super.finishClone(pos);
038    }*/
039    @Override
040    public boolean setEditItemMenu(JPopupMenu popup) {
041        String txt = Bundle.getMessage("editShape", Bundle.getMessage("Ellipse"));
042        popup.add(new javax.swing.AbstractAction(txt) {
043            @Override
044            public void actionPerformed(ActionEvent e) {
045                makeEditFrame(false);
046            }
047        });
048        return true;
049    }
050
051    @Override
052    protected DrawFrame makeEditFrame(boolean create) {
053        _editFrame = new DrawEllipse("editShape", "Ellipse", this, getEditor(), create);
054        _editFrame.setDisplayParams(this);
055        return _editFrame;
056    }
057
058}