use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class RecordStoreLayer method getRecords.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public <R extends LayerRecord> List<R> getRecords(BoundingBox boundingBox) {
if (hasGeometryField()) {
boundingBox = convertBoundingBox(boundingBox);
if (Property.hasValue(boundingBox)) {
try (final BaseCloseable booleanValueCloseable = eventsDisabled()) {
final BoundingBox queryBoundingBox = convertBoundingBox(boundingBox);
boolean covers;
synchronized (getSync()) {
covers = this.loadedBoundingBox.covers(queryBoundingBox);
}
if (covers) {
return getRecordsIndex(queryBoundingBox);
} else {
final List<R> records = (List) getRecordsPersisted(queryBoundingBox);
return records;
}
}
}
}
return Collections.emptyList();
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class MarkerStyleRenderer method renderMarker.
/**
* Point must be in the same geometry factory as the view.
*
* @param viewport
* @param graphics
* @param point
* @param style
*/
public static void renderMarker(final Viewport2D viewport, final Graphics2D graphics, Point point, final MarkerStyle style, final double orientation) {
point = getGeometry(viewport, point);
if (Property.hasValue(point)) {
final Paint paint = graphics.getPaint();
try (BaseCloseable transformClosable = viewport.setUseModelCoordinates(graphics, false)) {
final Marker marker = style.getMarker();
final double x = point.getX();
final double y = point.getY();
marker.render(viewport, graphics, style, x, y, orientation);
} catch (final Throwable e) {
Logs.debug(MarkerStyleRenderer.class, "Unable to render marker: " + style, e);
} finally {
graphics.setPaint(paint);
}
}
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class SvgMarker method render.
@Override
public void render(final Viewport2D viewport, final Graphics2D graphics, final MarkerStyle style, final double modelX, final double modelY, double orientation) {
final TranscoderInput transcoderInput = this.transcoderInput;
if (transcoderInput != null) {
try (BaseCloseable transformCloseable = new CloseableAffineTransform(graphics)) {
Viewport2D.setUseModelCoordinates(viewport, graphics, false);
final Quantity<Length> markerWidth = style.getMarkerWidth();
final double mapWidth = Viewport2D.toDisplayValue(viewport, markerWidth);
final Quantity<Length> markerHeight = style.getMarkerHeight();
final double mapHeight = Viewport2D.toDisplayValue(viewport, markerHeight);
final String orientationType = style.getMarkerOrientationType();
if ("none".equals(orientationType)) {
orientation = 0;
}
Viewport2D.translateModelToViewCoordinates(viewport, graphics, modelX, modelY);
final double markerOrientation = style.getMarkerOrientation();
orientation = orientation + markerOrientation;
if (orientation != 0) {
graphics.rotate(Math.toRadians(orientation));
}
final Quantity<Length> deltaX = style.getMarkerDx();
final Quantity<Length> deltaY = style.getMarkerDy();
double dx = Viewport2D.toDisplayValue(viewport, deltaX);
double dy = Viewport2D.toDisplayValue(viewport, deltaY);
final String verticalAlignment = style.getMarkerVerticalAlignment();
if ("bottom".equals(verticalAlignment)) {
dy -= mapHeight;
} else if ("middle".equals(verticalAlignment)) {
dy -= mapHeight / 2;
}
final String horizontalAlignment = style.getMarkerHorizontalAlignment();
if ("right".equals(horizontalAlignment)) {
dx -= mapWidth;
} else if ("center".equals(horizontalAlignment)) {
dx -= mapWidth / 2;
}
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
graphics.translate(dx, dy);
// changeAttribute(root, "stroke", "#ffffff",
// WebColors.toHex(style.getMarkerLineColor()));
// changeAttribute(root, "color", "#ffffff",
// WebColors.toHex(style.getMarkerLineColor()));
// changeAttribute(root, "fill", "#ffffff",
// WebColors.toHex(style.getMarkerLineColor()));
//
// changeAttribute(root, "stroke", "#000000",
// WebColors.toHex(style.getMarkerFill()));
// changeAttribute(root, "color", "#000000",
// WebColors.toHex(style.getMarkerFill()));
// changeAttribute(root, "fill", "#000000",
// WebColors.toHex(style.getMarkerFill()));
// changeAttribute(root, "stroke", "#444444",
// WebColors.toHex(style.getMarkerFill()));
// changeAttribute(root, "color", "#444444",
// WebColors.toHex(style.getMarkerFill()));
// changeAttribute(root, "fill", "#444444",
// WebColors.toHex(style.getMarkerFill()));
// shape.render(graphics);
final Graphics2DTranscoder transcoder = new Graphics2DTranscoder(graphics);
synchronized (transcoderInput) {
transcoder.transcode(transcoderInput, null);
}
} catch (final Throwable e) {
Logs.error(this, "Unable to render", e);
}
}
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class GeometryRecordReader method closeDo.
@Override
protected void closeDo() {
final Iterator<Geometry> geometryIterator = this.geometryIterator;
this.geometryIterator = null;
if (geometryIterator instanceof BaseCloseable) {
final BaseCloseable closeable = (BaseCloseable) geometryIterator;
closeable.close();
}
final GeometryReader geometryReader = this.geometryReader;
this.geometryReader = null;
if (geometryReader != null) {
geometryReader.close();
}
super.closeDo();
}
use of com.revolsys.io.BaseCloseable in project com.revolsys.open by revolsys.
the class RecordReader method readRecordsById.
default Map<Identifier, Record> readRecordsById() {
try (BaseCloseable closeable = this) {
final Map<Identifier, Record> recordsById = new TreeMap<>(Identifier.comparator());
for (final Record record : this) {
final Identifier identifier = record.getIdentifier();
recordsById.put(identifier, record);
}
return recordsById;
}
}
Aggregations