Search in sources :

Example 91 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class MergedValuePredicate method isHighlighted.

@Override
public boolean isHighlighted(final Component renderer, final ComponentAdapter adapter) {
    try {
        final int rowIndex = adapter.convertRowIndexToView(adapter.row);
        final int columnIndex = adapter.convertColumnIndexToView(adapter.column);
        final Record record = this.model.getRecord(rowIndex);
        final Record mergedRecord = this.model.getMergedRecord();
        if (record == mergedRecord) {
            return false;
        } else {
            final String fieldName = this.model.getColumnFieldName(columnIndex);
            final FieldDefinition field = this.model.getColumnFieldDefinition(columnIndex);
            if (field != null) {
                final Object value = record.getValue(fieldName);
                final Object mergedValue = mergedRecord.getValue(fieldName);
                if (value instanceof Geometry) {
                    return false;
                } else if (mergedValue instanceof Geometry) {
                    return false;
                } else {
                    return !field.equals(value, mergedValue);
                }
            }
        }
    } catch (final IndexOutOfBoundsException e) {
    }
    return false;
}
Also used : Geometry(com.revolsys.geometry.model.Geometry) FieldDefinition(com.revolsys.record.schema.FieldDefinition) Record(com.revolsys.record.Record)

Example 92 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class WikipediaBoundingBoxLayerWorker method handleBackground.

@Override
protected List<LayerRecord> handleBackground() {
    BoundingBox boundingBox = this.boundingBox;
    GeometryFactory geometryFactory = this.geometryFactory;
    final CoordinateSystem coordinateSystem = geometryFactory.getCoordinateSystem();
    if (coordinateSystem instanceof ProjectedCoordinateSystem) {
        final ProjectedCoordinateSystem projCs = (ProjectedCoordinateSystem) coordinateSystem;
        geometryFactory = projCs.getGeographicCoordinateSystem().getGeometryFactory();
        boundingBox = boundingBox.convert(geometryFactory);
    }
    final List<LayerRecord> results = (List) this.geoNamesService.getWikipediaArticles(boundingBox);
    for (final Record record : results) {
        final String title = record.getValue("title");
        final String wikipediaUrl = record.getValue("wikipediaUrl");
        final String thumbnailImage = record.getValue("thumbnailImg");
        final Point point = record.getGeometry();
        String text;
        if (thumbnailImage != null) {
            text = "<html><b>" + title + "</b><br /><img src=\"" + thumbnailImage + "\" /><br /></html>";
        } else {
            text = "<html><b>" + title + "</b><br /></html>";
        }
    // if (viewport instanceof ComponentViewport2D) {
    // final ComponentViewport2D componentViewport =
    // (ComponentViewport2D)viewport;
    // componentViewport.addHotSpot(geometryFactory, point, text, "http://"
    // + wikipediaUrl);
    // }
    }
    return results;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) CoordinateSystem(com.revolsys.geometry.cs.CoordinateSystem) BoundingBox(com.revolsys.geometry.model.BoundingBox) ProjectedCoordinateSystem(com.revolsys.geometry.cs.ProjectedCoordinateSystem) List(java.util.List) Record(com.revolsys.record.Record) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) LayerRecord(com.revolsys.swing.map.layer.record.LayerRecord) Point(com.revolsys.geometry.model.Point)

Example 93 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class RecordListCellRenderer method getListCellRendererComponent.

@Override
public Component getListCellRendererComponent(final JList list, final Object cellValue, final int index, final boolean isSelected, final boolean cellHasFocus) {
    super.getListCellRendererComponent(list, cellValue, index, isSelected, cellHasFocus);
    if (cellValue instanceof Record) {
        final Record object = (Record) cellValue;
        final Object value = object.getValue(this.fieldName);
        final String text = DataTypes.toString(value);
        setText(text);
    }
    return this;
}
Also used : Record(com.revolsys.record.Record)

Example 94 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class GeoNamesService method mapToObjects.

private List<Record> mapToObjects(final RecordDefinition recordDefinition, final Map<String, Object> result) {
    final List<Record> results = new ArrayList<>();
    final List<Map<String, Object>> names = (List<Map<String, Object>>) result.get("geonames");
    for (final Map<String, Object> name : names) {
        final Record record = recordDefinition.newRecord();
        for (final String fieldName : recordDefinition.getFieldNames()) {
            final Object value = name.get(fieldName);
            if (value != null) {
                record.setValue(fieldName, value);
            }
        }
        final double lat = ((Number) name.get("lat")).doubleValue();
        final double lon = ((Number) name.get("lng")).doubleValue();
        Point coordinate = new PointDoubleXY(lon, lat);
        final Number elevation = (Number) name.get("elevation");
        if (elevation == null) {
            coordinate = new PointDoubleXY(lon, lat);
        } else {
            coordinate = new PointDoubleXYZ(lon, lat, elevation.doubleValue());
        }
        record.setGeometryValue(GeometryFactory.DEFAULT_3D.point(coordinate));
        results.add(record);
    }
    return results;
}
Also used : ArrayList(java.util.ArrayList) Point(com.revolsys.geometry.model.Point) PointDoubleXYZ(com.revolsys.geometry.model.impl.PointDoubleXYZ) Record(com.revolsys.record.Record) ArrayList(java.util.ArrayList) List(java.util.List) PointDoubleXY(com.revolsys.geometry.model.impl.PointDoubleXY) HashMap(java.util.HashMap) Map(java.util.Map)

Example 95 with Record

use of com.revolsys.record.Record in project com.revolsys.open by revolsys.

the class AbstractProxyLayerRecord method setValue.

@Override
protected boolean setValue(final FieldDefinition fieldDefinition, final Object value) {
    final int index = fieldDefinition.getIndex();
    final Record record = getRecord();
    return record.setValue(index, value);
}
Also used : Record(com.revolsys.record.Record)

Aggregations

Record (com.revolsys.record.Record)198 ArrayRecord (com.revolsys.record.ArrayRecord)43 RecordReader (com.revolsys.record.io.RecordReader)34 RecordDefinition (com.revolsys.record.schema.RecordDefinition)34 Geometry (com.revolsys.geometry.model.Geometry)29 LineString (com.revolsys.geometry.model.LineString)21 Point (com.revolsys.geometry.model.Point)20 ChannelWriter (com.revolsys.io.channels.ChannelWriter)19 Identifier (com.revolsys.identifier.Identifier)17 ArrayList (java.util.ArrayList)16 FieldDefinition (com.revolsys.record.schema.FieldDefinition)15 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)14 LayerRecord (com.revolsys.swing.map.layer.record.LayerRecord)13 NoSuchElementException (java.util.NoSuchElementException)13 DataType (com.revolsys.datatype.DataType)10 Query (com.revolsys.record.query.Query)9 HashMap (java.util.HashMap)9 List (java.util.List)8 LinkedHashMap (java.util.LinkedHashMap)7 Edge (com.revolsys.geometry.graph.Edge)6