@Override protected void onInit(GL2 gl) { texture = GLUtils.createTexture(gl, MatsimResource.getAsInputStream("icon18.png")); }
private void copyResourceToFile(final String resourceFilename, final String destinationFilename) throws IOException { InputStream inStream = null; OutputStream outStream = null; try { inStream = MatsimResource.getAsInputStream(resourceFilename); outStream = new FileOutputStream(destinationFilename); IOUtils.copyStream(inStream, outStream); } finally { if (inStream != null) { inStream.close(); } if (outStream != null) { outStream.close(); } } }
this.writer.addNonKMLFile(MatsimResource.getAsInputStream("car.png"), "data/car.png"); iconLink.setHref("./car.png"); } catch (IOException e1) {
@Override public StyleType createDefaultNetworkNodeStyle() throws IOException { if (this.defaultnetworknodestyle == null) { this.defaultnetworknodestyle = kmlObjectFactory.createStyleType(); this.defaultnetworknodestyle.setId("defaultnetworknodestyle"); LinkType iconLink = kmlObjectFactory.createLinkType(); iconLink.setHref(DEFAULTNODEICON); this.writer.addNonKMLFile(MatsimResource.getAsInputStream(DEFAULTNODEICONRESOURCE), DEFAULTNODEICON); IconStyleType iStyle = kmlObjectFactory.createIconStyleType(); iStyle.setIcon(iconLink); iStyle.setColor(MatsimKmlStyleFactory.MATSIMRED); iStyle.setScale(MatsimKmlStyleFactory.ICONSCALE); this.defaultnetworknodestyle.setIconStyle(iStyle); this.document.getAbstractStyleSelectorGroup().add(kmlObjectFactory.createStyle(this.defaultnetworknodestyle)); } return this.defaultnetworknodestyle; }
.getAsInputStream("icons/plus.png"), CROSSICON); this.writer.addNonKMLFile(MatsimResource .getAsInputStream("icons/minus.png"), MINUSICON); } catch (IOException e) { log.error("Could not copy copy plus-/minus-icons to the KMZ.", e);
long iconFileSize = ByteStreams.toByteArray(MatsimResource.getAsInputStream(MatsimKmlStyleFactory.DEFAULTNODEICONRESOURCE)).length; assertEquals("uncompressed size of icon is wrong.", iconFileSize, linkIconEntry.getSize()); assertEquals("uncompressed size of icon is wrong.", iconFileSize, nodeIconEntry.getSize());
@Override public StyleType createDefaultNetworkLinkStyle() throws IOException { if (this.defaultnetworklinkstyle == null) { this.defaultnetworklinkstyle = kmlObjectFactory.createStyleType(); this.defaultnetworklinkstyle.setId("defaultnetworklinkstyle"); LinkType iconLink = kmlObjectFactory.createLinkType(); iconLink.setHref(DEFAULTLINKICON); this.writer.addNonKMLFile(MatsimResource.getAsInputStream(DEFAULTNODEICONRESOURCE), DEFAULTLINKICON); IconStyleType iStyle = kmlObjectFactory.createIconStyleType(); iStyle.setIcon(iconLink); iStyle.setColor(MatsimKmlStyleFactory.MATSIMWHITE); iStyle.setScale(MatsimKmlStyleFactory.ICONSCALE); this.defaultnetworklinkstyle.setIconStyle(iStyle); LineStyleType lineStyle = kmlObjectFactory.createLineStyleType(); lineStyle.setColor(MatsimKmlStyleFactory.MATSIMGREY); lineStyle.setWidth(12.0); this.defaultnetworklinkstyle.setLineStyle(lineStyle); this.document.getAbstractStyleSelectorGroup().add(kmlObjectFactory.createStyle(this.defaultnetworklinkstyle)); } return this.defaultnetworklinkstyle; }
this.writer.addNonKMLFile(MatsimResource.getAsInputStream("icons/circle.png"), CIRCLEICON); this.writer.addNonKMLFile(MatsimResource.getAsInputStream("icons/plus.png"), CROSSICON); this.writer.addNonKMLFile(MatsimResource.getAsInputStream("icons/minus.png"), MINUSICON); } catch (IOException e) { log.error("Could not copy copy plus-/minus-icons to the KMZ.", e);
@Override public void init(GLAutoDrawable drawable) { GL2 gl = drawable.getGL().getGL2(); this.textRenderer = new TextRenderer(new Font("SansSerif", Font.PLAIN, 32), true, false); gl.setSwapInterval(0); float[] components = otfVisConfig.getBackgroundColor().getColorComponents(new float[4]); gl.glClearColor(components[0], components[1], components[2], components[3]); gl.glClear( GL2.GL_COLOR_BUFFER_BIT | GL2.GL_DEPTH_BUFFER_BIT); if (!glInited) { // This method can (and will) be called several times. // (Gl contexts can change without notice.) float minEasting = (float)clientQ.getMinEasting(); float minNorthing = (float)clientQ.getMinNorthing(); float maxNorthing = (float)clientQ.getMaxNorthing(); double aspectRatio = (double) drawable.getSurfaceWidth() / (double) drawable.getSurfaceHeight(); double pixelRatio = (double) drawable.getSurfaceHeight() / (double) (maxNorthing-minNorthing); this.scale = 1.0f / (float) pixelRatio; this.viewBounds = new QuadTree.Rect(minEasting, minNorthing, minEasting + (maxNorthing - minNorthing) * aspectRatio, maxNorthing); if (otfVisConfig.isMapOverlayMode()) { setScale(nearestPowerOfTwo(this.scale)); } int time = this.hostControlBar.getSimTime(); QuadTree.Rect rect = new QuadTree.Rect((float)clientQ.getMinEasting(), (float)clientQ.getMinNorthing(), (float)clientQ.getMaxEasting(), (float)clientQ.getMaxNorthing()); this.currentSceneGraph = this.clientQ.getSceneGraph(time, rect); } marker = GLUtils.createTexture(gl, MatsimResource.getAsInputStream("otfvis/marker.png")); currentSceneGraph.glInit(); glInited = true; }
/** * Creates a legend * @return a ScreenOverlay read from a file * @throws IOException */ private ScreenOverlayType createLegend() throws IOException { this.writer.addNonKMLFile(MatsimResource.getAsInputStream("countsKml/countsLegend240x300.png"), "countsLegend.png"); ScreenOverlayType overlay = this.kmlObjectFactory.createScreenOverlayType(); LinkType icon = this.kmlObjectFactory.createLinkType(); icon.setHref("./countsLegend.png"); overlay.setIcon(icon); overlay.setName("Legend"); // place the image bottom left Vec2Type overlayXY = this.kmlObjectFactory.createVec2Type(); overlayXY.setX(0.0); overlayXY.setY(0.0); overlayXY.setXunits(UnitsEnumType.FRACTION); overlayXY.setYunits(UnitsEnumType.FRACTION); overlay.setOverlayXY(overlayXY); Vec2Type screenXY = this.kmlObjectFactory.createVec2Type(); screenXY.setX(0.02); screenXY.setY(0.07); screenXY.setXunits(UnitsEnumType.FRACTION); screenXY.setYunits(UnitsEnumType.FRACTION); overlay.setScreenXY(screenXY); return overlay; }
/** * Creates a legend * * @return a ScreenOverlay read from a file * @throws IOException */ private ScreenOverlayType createLegend() throws IOException { this.writer.addNonKMLFile(MatsimResource .getAsInputStream("countsKml/countsLegend240x300.png"), "countsLegend.png"); ScreenOverlayType overlay = kmlObjectFactory.createScreenOverlayType(); LinkType icon = kmlObjectFactory.createLinkType(); icon.setHref("./countsLegend.png"); overlay.setIcon(icon); overlay.setName("Legend"); // place the image bottom left Vec2Type overlayXY = kmlObjectFactory.createVec2Type(); overlayXY.setX(0.0); overlayXY.setY(0.0); overlayXY.setXunits(UnitsEnumType.FRACTION); overlayXY.setYunits(UnitsEnumType.FRACTION); overlay.setOverlayXY(overlayXY); Vec2Type screenXY = kmlObjectFactory.createVec2Type(); screenXY.setX(0.02); screenXY.setY(0.07); screenXY.setXunits(UnitsEnumType.FRACTION); screenXY.setYunits(UnitsEnumType.FRACTION); overlay.setScreenXY(screenXY); return overlay; }
/** * Creates a legend * @return a ScreenOverlay read from a file * @throws IOException */ private ScreenOverlayType createLegendGEH() throws IOException { this.writer.addNonKMLFile(MatsimResource.getAsInputStream("countsKml/countsLegendGEH.png"), "countsLegendGEH.png"); ScreenOverlayType overlay = this.kmlObjectFactory.createScreenOverlayType(); LinkType icon = this.kmlObjectFactory.createLinkType(); icon.setHref("./countsLegendGEH.png"); overlay.setIcon(icon); overlay.setName("Legend GEH"); // place the image bottom left Vec2Type overlayXY = this.kmlObjectFactory.createVec2Type(); overlayXY.setX(0.0); overlayXY.setY(0.0); overlayXY.setXunits(UnitsEnumType.FRACTION); overlayXY.setYunits(UnitsEnumType.FRACTION); overlay.setOverlayXY(overlayXY); Vec2Type screenXY = this.kmlObjectFactory.createVec2Type(); screenXY.setX(0.02); screenXY.setY(0.07); screenXY.setXunits(UnitsEnumType.FRACTION); screenXY.setYunits(UnitsEnumType.FRACTION); overlay.setScreenXY(screenXY); overlay.setVisibility(Boolean.FALSE); return overlay; }
/** * Creates a legend * @return a ScreenOverlay read from a file * @throws IOException */ private ScreenOverlayType createLegendNormalized() throws IOException { this.writer.addNonKMLFile(MatsimResource.getAsInputStream("countsKml/countsLegendNormalized.png"), "countsLegendNormalized.png"); ScreenOverlayType overlay = this.kmlObjectFactory.createScreenOverlayType(); LinkType icon = this.kmlObjectFactory.createLinkType(); icon.setHref("./countsLegendNormalized.png"); overlay.setIcon(icon); overlay.setName("Legend Normalized"); // place the image bottom left Vec2Type overlayXY = this.kmlObjectFactory.createVec2Type(); overlayXY.setX(0.0); overlayXY.setY(0.0); overlayXY.setXunits(UnitsEnumType.FRACTION); overlayXY.setYunits(UnitsEnumType.FRACTION); overlay.setOverlayXY(overlayXY); Vec2Type screenXY = this.kmlObjectFactory.createVec2Type(); screenXY.setX(0.02); screenXY.setY(0.07); screenXY.setXunits(UnitsEnumType.FRACTION); screenXY.setYunits(UnitsEnumType.FRACTION); overlay.setScreenXY(screenXY); overlay.setVisibility(Boolean.FALSE); return overlay; }
writer.addNonKMLFile(MatsimResource.getAsInputStream("matsim_logo_transparent.png"), "matsimLogo.png");