Search in sources :

Example 11 with Identifier

use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method getCodes.

@Override
public Map<Identifier, List<Object>> getCodes() {
    if (this.codes == null) {
        final Map<Identifier, List<Object>> codesById = new HashMap<>();
        for (final CoordinateSystem coordinateSystem : coordinateSystems) {
            final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
            final Identifier id = Identifier.newIdentifier(coordinateSystemId);
            final List<Object> code = Collections.singletonList(coordinateSystem);
            codesById.put(id, code);
        }
        this.codes = codesById;
    }
    return this.codes;
}
Also used : Identifier(com.revolsys.identifier.Identifier) IntHashMap(com.revolsys.collection.map.IntHashMap) HashMap(java.util.HashMap) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeocentricCoordinateSystem(com.revolsys.geometry.cs.GeocentricCoordinateSystem) CompoundCoordinateSystem(com.revolsys.geometry.cs.CompoundCoordinateSystem) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) EngineeringCoordinateSystem(com.revolsys.geometry.cs.EngineeringCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) List(java.util.List) ArrayList(java.util.ArrayList)

Example 12 with Identifier

use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.

the class EpsgCoordinateSystems method getIdentifiers.

@Override
public List<Identifier> getIdentifiers() {
    if (this.identifiers == null) {
        final List<Identifier> identifiers = new ArrayList<>();
        for (final CoordinateSystem coordinateSystem : coordinateSystems) {
            final int coordinateSystemId = coordinateSystem.getCoordinateSystemId();
            final Identifier id = Identifier.newIdentifier(coordinateSystemId);
            identifiers.add(id);
        }
        this.identifiers = Collections.unmodifiableList(identifiers);
    }
    return this.identifiers;
}
Also used : Identifier(com.revolsys.identifier.Identifier) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) GeocentricCoordinateSystem(com.revolsys.geometry.cs.GeocentricCoordinateSystem) CompoundCoordinateSystem(com.revolsys.geometry.cs.CompoundCoordinateSystem) VerticalCoordinateSystem(com.revolsys.geometry.cs.VerticalCoordinateSystem) EngineeringCoordinateSystem(com.revolsys.geometry.cs.EngineeringCoordinateSystem) GeographicCoordinateSystem(com.revolsys.geometry.cs.GeographicCoordinateSystem) ArrayList(java.util.ArrayList)

Example 13 with Identifier

use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.

the class Record method isSame.

default boolean isSame(final Record record) {
    if (record == null) {
        return false;
    } else {
        if (this == record) {
            return true;
        } else {
            synchronized (this) {
                if (record.getRecordDefinition() == getRecordDefinition()) {
                    final Identifier id = getIdentifier();
                    final Identifier otherId = record.getIdentifier();
                    if (id == null || otherId == null) {
                        return false;
                    } else if (DataType.equal(id, otherId)) {
                        return true;
                    } else {
                        return false;
                    }
                } else {
                    return false;
                }
            }
        }
    }
}
Also used : TypedIdentifier(com.revolsys.identifier.TypedIdentifier) Identifier(com.revolsys.identifier.Identifier) ListIdentifier(com.revolsys.identifier.ListIdentifier)

Example 14 with Identifier

use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.

the class CodeTableValueComparator method compare.

@Override
public int compare(final Object object1, final Object object2) {
    final Identifier identifier1 = Identifier.newIdentifier(object1);
    final Identifier identifier2 = Identifier.newIdentifier(object2);
    if (identifier1 == null) {
        if (identifier2 == null) {
            return 0;
        } else {
            return -1;
        }
    } else if (identifier2 == null) {
        return 1;
    } else if (identifier1.equals(identifier2)) {
        return 0;
    } else {
        final Object value1 = this.codeTable.getValue(identifier1);
        final Object value2 = this.codeTable.getValue(identifier2);
        int compare = CompareUtil.compare(value1, value2);
        if (compare == 0) {
            compare = identifier1.compareTo(identifier2);
        }
        return compare;
    }
}
Also used : Identifier(com.revolsys.identifier.Identifier)

Example 15 with Identifier

use of com.revolsys.identifier.Identifier in project com.revolsys.open by revolsys.

the class SwingUtil method newComboBox.

static ComboBox<Identifier> newComboBox(final String fieldName, final CodeTable codeTable, final boolean required, final int maxLength, final boolean idSuffix) {
    if (codeTable == null) {
        return null;
    } else {
        final ComboBox<Identifier> comboBox = CodeTableComboBoxModel.newComboBox(fieldName, codeTable, !required, idSuffix);
        if (comboBox.getModel().getSize() > 0) {
            comboBox.setSelectedIndex(0);
        }
        int longestLength = -1;
        for (final Entry<Identifier, List<Object>> codes : codeTable.getCodes().entrySet()) {
            int length = 0;
            if (idSuffix) {
                final Identifier identifier = codes.getKey();
                length += identifier.toString().length() + 3;
            }
            final List<Object> values = codes.getValue();
            if (values != null && !values.isEmpty()) {
                final String text = Strings.toString(values);
                length += text.length();
            }
            if (length > longestLength) {
                longestLength = length;
            }
        }
        if (longestLength == -1) {
            longestLength = 10;
        }
        if (maxLength > 0 && longestLength > maxLength) {
            longestLength = maxLength;
        }
        final StringBuilder value = new StringBuilder();
        for (int i = 0; i < longestLength; i++) {
            value.append("W");
        }
        comboBox.setPrototypeDisplayValue(Identifier.newIdentifier(value));
        final ComboBoxEditor editor = comboBox.getEditor();
        final Component editorComponent = editor.getEditorComponent();
        if (editorComponent instanceof JTextComponent) {
            final JTextField textComponent = (JTextField) editorComponent;
            textComponent.setColumns((int) (longestLength * 0.8));
            final MenuFactory menu = MenuFactory.getPopupMenuFactory(textComponent);
            MenuFactory.addToComponent(comboBox, menu);
        } else {
            MenuFactory.getPopupMenuFactory(comboBox);
        }
        return comboBox;
    }
}
Also used : JTextComponent(javax.swing.text.JTextComponent) JTextField(javax.swing.JTextField) ComboBoxEditor(javax.swing.ComboBoxEditor) Point(java.awt.Point) Identifier(com.revolsys.identifier.Identifier) MenuFactory(com.revolsys.swing.menu.MenuFactory) List(java.util.List) ArrayList(java.util.ArrayList) JList(javax.swing.JList) Component(java.awt.Component) JComponent(javax.swing.JComponent) JTextComponent(javax.swing.text.JTextComponent)

Aggregations

Identifier (com.revolsys.identifier.Identifier)56 Record (com.revolsys.record.Record)17 ArrayList (java.util.ArrayList)12 RecordDefinition (com.revolsys.record.schema.RecordDefinition)11 SingleIdentifier (com.revolsys.identifier.SingleIdentifier)8 ListIdentifier (com.revolsys.identifier.ListIdentifier)7 TypedIdentifier (com.revolsys.identifier.TypedIdentifier)6 CodeTable (com.revolsys.record.code.CodeTable)6 RecordReader (com.revolsys.record.io.RecordReader)5 RecordStore (com.revolsys.record.schema.RecordStore)5 Transaction (com.revolsys.transaction.Transaction)5 List (java.util.List)5 Geometry (com.revolsys.geometry.model.Geometry)4 BaseCloseable (com.revolsys.io.BaseCloseable)4 PathName (com.revolsys.io.PathName)4 ArrayRecord (com.revolsys.record.ArrayRecord)4 Query (com.revolsys.record.query.Query)4 OsmElement (com.revolsys.record.io.format.openstreetmap.model.OsmElement)3 FieldDefinition (com.revolsys.record.schema.FieldDefinition)3 CompoundCoordinateSystem (com.revolsys.geometry.cs.CompoundCoordinateSystem)2