Search in sources :

Example 1 with RoadClass

use of us.mn.state.dot.tms.RoadClass in project iris by mnit-rtmc.

the class RoadModel method createColumns.

/**
 * Create the columns in the model
 */
@Override
protected ArrayList<ProxyColumn<Road>> createColumns() {
    ArrayList<ProxyColumn<Road>> cols = new ArrayList<ProxyColumn<Road>>(4);
    cols.add(new ProxyColumn<Road>("location.road", 200) {

        public Object getValueAt(Road r) {
            return r.getName();
        }
    });
    cols.add(new ProxyColumn<Road>("location.road.abbrev", 80) {

        public Object getValueAt(Road r) {
            return r.getAbbrev();
        }

        public boolean isEditable(Road r) {
            return canWrite(r);
        }

        public void setValueAt(Road r, Object value) {
            r.setAbbrev(value.toString());
        }
    });
    cols.add(new ProxyColumn<Road>("location.road.class", 120) {

        public Object getValueAt(Road r) {
            return RoadClass.fromOrdinal(r.getRClass());
        }

        public boolean isEditable(Road r) {
            return canWrite(r);
        }

        public void setValueAt(Road r, Object value) {
            if (value instanceof RoadClass) {
                RoadClass c = (RoadClass) value;
                r.setRClass((short) c.ordinal());
            }
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<RoadClass> cbx = new JComboBox<RoadClass>(RoadClass.values());
            return new DefaultCellEditor(cbx);
        }
    });
    cols.add(new ProxyColumn<Road>("location.direction", 120) {

        public Object getValueAt(Road r) {
            return Direction.fromOrdinal(r.getDirection());
        }

        public boolean isEditable(Road r) {
            return canWrite(r);
        }

        public void setValueAt(Road r, Object value) {
            if (value instanceof Direction) {
                Direction d = (Direction) value;
                r.setDirection((short) d.ordinal());
            }
        }

        protected TableCellEditor createCellEditor() {
            JComboBox<Direction> cbx = new JComboBox<Direction>(Direction.values());
            return new DefaultCellEditor(cbx);
        }
    });
    return cols;
}
Also used : JComboBox(javax.swing.JComboBox) Road(us.mn.state.dot.tms.Road) ArrayList(java.util.ArrayList) RoadClass(us.mn.state.dot.tms.RoadClass) Direction(us.mn.state.dot.tms.Direction) DefaultCellEditor(javax.swing.DefaultCellEditor) TableCellEditor(javax.swing.table.TableCellEditor) ProxyColumn(us.mn.state.dot.tms.client.proxy.ProxyColumn)

Example 2 with RoadClass

use of us.mn.state.dot.tms.RoadClass in project iris by mnit-rtmc.

the class MapSegment method roadClassScale.

/**
 * Get the scale factor for the road class
 */
private float roadClassScale() {
    Road r = getR_Node().getGeoLoc().getRoadway();
    RoadClass rc = RoadClass.fromOrdinal(r.getRClass());
    return rc.scale * UI.scale;
}
Also used : Road(us.mn.state.dot.tms.Road) RoadClass(us.mn.state.dot.tms.RoadClass)

Aggregations

Road (us.mn.state.dot.tms.Road)2 RoadClass (us.mn.state.dot.tms.RoadClass)2 ArrayList (java.util.ArrayList)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1 JComboBox (javax.swing.JComboBox)1 TableCellEditor (javax.swing.table.TableCellEditor)1 Direction (us.mn.state.dot.tms.Direction)1 ProxyColumn (us.mn.state.dot.tms.client.proxy.ProxyColumn)1