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