Author: paperwing
Date: 2012-01-23 14:23:27 -0800 (Mon, 23 Jan 2012)
New Revision: 28076
Added:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/StringRenderer.java
Removed:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePicker.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/TextRenderer.java
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/DefaultShapePickingProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePickingProcessor.java
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
Log:
removed unused shapePicker class, testing rendering text with JOGL's
TextRenderer class
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
2012-01-23 22:04:00 UTC (rev 28075)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/MainGraphicsHandler.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -20,7 +20,7 @@
import org.cytoscape.paperwing.internal.rendering.RenderNodesProcedure;
import org.cytoscape.paperwing.internal.rendering.RenderSelectionBoxProcedure;
import org.cytoscape.paperwing.internal.rendering.ResetSceneProcedure;
-import org.cytoscape.paperwing.internal.rendering.text.TextRenderer;
+import org.cytoscape.paperwing.internal.rendering.text.StringRenderer;
import org.cytoscape.view.model.CyNetworkView;
public class MainGraphicsHandler implements GraphicsHandler {
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/DefaultShapePickingProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/DefaultShapePickingProcessor.java
2012-01-23 22:04:00 UTC (rev 28075)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/DefaultShapePickingProcessor.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -14,7 +14,6 @@
import org.cytoscape.paperwing.internal.geometric.Vector3;
import org.cytoscape.paperwing.internal.input.KeyboardMonitor;
import org.cytoscape.paperwing.internal.input.MouseMonitor;
-import org.cytoscape.paperwing.internal.picking.ShapePicker.PickResults;
import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
import org.cytoscape.paperwing.internal.tools.SimpleCamera;
Deleted:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePicker.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePicker.java
2012-01-23 22:04:00 UTC (rev 28075)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePicker.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -1,221 +0,0 @@
-package org.cytoscape.paperwing.internal.picking;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.IntBuffer;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.media.opengl.GL;
-import javax.media.opengl.GL2;
-import javax.media.opengl.glu.GLU;
-
-import org.cytoscape.paperwing.internal.data.GraphicsData;
-import org.cytoscape.paperwing.internal.geometric.Vector3;
-import org.cytoscape.paperwing.internal.rendering.ReadOnlyGraphicsProcedure;
-import org.cytoscape.paperwing.internal.tools.SimpleCamera;
-
-public class ShapePicker {
-
- /** A constant that stands for "no type is here" */
- public static final int NO_TYPE = -1;
-
- /** A constant representing the type node */
- public static final int NODE_TYPE = 0;
-
- /** A constant representing the type edge */
- public static final int EDGE_TYPE = 1;
-
- /** A constant that stands for "no index is here" */
- // TODO: NO_INDEX relies on cytoscape's guarantee that node and edge
indices
- // are nonnegative
- public static final int NO_INDEX = -1; // Value representing that no
node
-
// or edge index is being held
-
- /**
- * A class capable of storing the edge and node indices of edges and
nodes
- * that were found to be selected using the shape picking methods
- */
- public class PickResults {
- public Set<Integer> nodeIndices = new LinkedHashSet<Integer>();
- public Set<Integer> edgeIndices = new LinkedHashSet<Integer>();
- }
-
- private GraphicsData graphicsData;
- private ReadOnlyGraphicsProcedure drawNodesProcedure;
- private ReadOnlyGraphicsProcedure drawEdgesProcedure;
-
- public ShapePicker(ReadOnlyGraphicsProcedure drawNodeProcedure,
- ReadOnlyGraphicsProcedure drawEdgeProcedure) {
- this.drawNodesProcedure = drawNodeProcedure;
- this.drawEdgesProcedure = drawEdgeProcedure;
- }
-
- /**
- * Perform a picking operation on the specified region to capture 3D
shapes
- * drawn in the given region
- *
- * @param gl
- * The {@link GL2} object used for rendering
- * @param x
- * The center x location, in window coordinates
- * @param y
- * The center y location, in window coordinates
- * @param width
- * The width of the box used for picking
- * @param height
- * The height of the box used for picking
- * @param selectAll
- * Whether or not to select all shapes captured in the given
- * region, or only to only take the frontmost one
- * @return The edges and nodes found in the region, as a {@link
PickResults}
- * object
- */
- public PickResults performPick(int x, int y, int width, int height,
- boolean selectAll, GraphicsData graphicsData) {
- int bufferSize = 1024;
-
- if (selectAll) {
- bufferSize = 8128;
- }
-
- GL2 gl = graphicsData.getGlContext();
- int screenHeight = graphicsData.getScreenHeight();
- int screenWidth = graphicsData.getScreenWidth();
- SimpleCamera camera = graphicsData.getCamera();
-
- ByteBuffer byteBuffer = ByteBuffer.allocateDirect(bufferSize);
- byteBuffer.order(ByteOrder.LITTLE_ENDIAN);
- IntBuffer buffer = byteBuffer.asIntBuffer();
-
- IntBuffer viewport = IntBuffer.allocate(4);
- gl.glGetIntegerv(GL2.GL_VIEWPORT, viewport);
-
- gl.glSelectBuffer(bufferSize / 4, buffer);
- gl.glRenderMode(GL2.GL_SELECT);
- gl.glInitNames();
-
- gl.glMatrixMode(GL2.GL_PROJECTION);
- gl.glPushMatrix();
-
- GLU glu = new GLU();
- gl.glLoadIdentity();
-
- glu.gluPickMatrix(x, screenHeight - y, width, height, viewport);
-
- if (screenHeight != 0) {
- glu.gluPerspective(45.0f, (float) screenWidth /
screenHeight, 0.2f,
- 50.0f);
- } else {
- glu.gluPerspective(45.0f, 1, 0.2f,
- 50.0f);
- }
-
- // don't think this ortho call is needed
- // gl.glOrtho(0.0, 8.0, 0.0, 8.0, -0.5, 2.5);
-
- // --Begin Drawing--
-
- gl.glMatrixMode(GL2.GL_MODELVIEW);
- gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
- gl.glLoadIdentity();
-
- // gl.glPushMatrix();
- Vector3 position = camera.getPosition();
- Vector3 target = camera.getTarget();
- Vector3 up = camera.getUp();
-
- glu.gluLookAt(position.x(), position.y(), position.z(),
target.x(),
- target.y(), target.z(), up.x(), up.y(), up.z());
-
- gl.glPushName(NODE_TYPE);
- gl.glPushName(NO_INDEX);
-
- // Render nodes for picking
- drawNodesProcedure.execute(graphicsData);
-
- gl.glPopName();
- gl.glPopName();
-
- gl.glPushName(EDGE_TYPE);
- gl.glPushName(NO_INDEX);
-
- // Render edges for picking
- drawEdgesProcedure.execute(graphicsData);
-
- gl.glPopName();
- gl.glPopName();
-
- // --End Drawing--
-
- gl.glMatrixMode(GL2.GL_PROJECTION);
- gl.glPopMatrix();
-
- gl.glMatrixMode(GL2.GL_MODELVIEW);
-
- // not sure if this is needed
- // gl.glFlush();
-
- int hits = gl.glRenderMode(GL2.GL_RENDER);
-
- int selectedIndex;
- int selectedType;
-
- // Current hit record is size 5 because we have
- // (numNames, minZ, maxZ, name1, name2) for
- // indices 0-4 respectively
- int sizeOfHitRecord = 5;
-
- PickResults results = new PickResults();
-
- if (hits > 0) {
- // The variable max helps keep track of the polygon
that is closest
- // to the front of the screen
- int max = buffer.get(2);
- int maxType = buffer.get(3);
-
- selectedType = buffer.get(3);
- selectedIndex = buffer.get(4);
-
- // Drag-selection; select all
- if (selectAll) {
- for (int i = 0; i < hits; i++) {
-
- selectedType = buffer.get(i *
sizeOfHitRecord + 3);
- selectedIndex = buffer.get(i *
sizeOfHitRecord + 4);
-
- if (selectedType == NODE_TYPE) {
-
results.nodeIndices.add(selectedIndex);
- } else if (selectedType == EDGE_TYPE) {
-
results.edgeIndices.add(selectedIndex);
- }
- }
- // Single selection
- } else {
- for (int i = 0; i < hits; i++) {
-
- if (buffer.get(i * sizeOfHitRecord + 2)
<= max
- && buffer.get(i *
sizeOfHitRecord + 3) <= maxType) {
-
- max = buffer.get(i *
sizeOfHitRecord + 2);
- maxType = buffer.get(i *
sizeOfHitRecord + 3);
-
- // We have that name1
represents the object type
- selectedType = buffer.get(i *
sizeOfHitRecord + 3);
-
- // name2 represents the object
index
- selectedIndex = buffer.get(i *
sizeOfHitRecord + 4);
- }
- }
-
- if (selectedType == NODE_TYPE) {
- results.nodeIndices.add(selectedIndex);
- } else if (selectedType == EDGE_TYPE) {
- results.edgeIndices.add(selectedIndex);
- }
- }
- }
-
- return results;
- }
-}
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePickingProcessor.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePickingProcessor.java
2012-01-23 22:04:00 UTC (rev 28075)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/picking/ShapePickingProcessor.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -14,7 +14,6 @@
import org.cytoscape.paperwing.internal.geometric.Vector3;
import org.cytoscape.paperwing.internal.input.KeyboardMonitor;
import org.cytoscape.paperwing.internal.input.MouseMonitor;
-import org.cytoscape.paperwing.internal.picking.ShapePicker.PickResults;
import org.cytoscape.paperwing.internal.tools.SimpleCamera;
import com.jogamp.newt.event.MouseEvent;
Modified:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
2012-01-23 22:04:00 UTC (rev 28075)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/RenderLabelsProcedure.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -1,5 +1,8 @@
package org.cytoscape.paperwing.internal.rendering;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.font.FontRenderContext;
import java.util.Set;
import javax.media.opengl.GL2;
@@ -8,29 +11,32 @@
import org.cytoscape.paperwing.internal.data.GraphicsData;
import org.cytoscape.paperwing.internal.geometric.Vector3;
import
org.cytoscape.paperwing.internal.rendering.shapes.ScalableShapeDrawer.ShapeType;
-import org.cytoscape.paperwing.internal.rendering.text.TextRenderer;
+import org.cytoscape.paperwing.internal.rendering.text.StringRenderer;
import org.cytoscape.paperwing.internal.tools.RenderColor;
import org.cytoscape.view.model.CyNetworkView;
import org.cytoscape.view.model.View;
import org.cytoscape.view.presentation.property.MinimalVisualLexicon;
import org.cytoscape.view.presentation.property.RichVisualLexicon;
+import com.jogamp.opengl.util.awt.TextRenderer;
+
public class RenderLabelsProcedure implements ReadOnlyGraphicsProcedure {
private static final float TEXT_SCALE = 0.045f;
private static final Vector3 TEXT_OFFSET = new Vector3 (0, 0.04, 0);
private TextRenderer textRenderer;
+ private Font defaultFont = new Font("Trebuchet MS", Font.PLAIN, 72);
public RenderLabelsProcedure() {
- textRenderer = new TextRenderer();
+ textRenderer = new TextRenderer(defaultFont);
}
@Override
public void initialize(GraphicsData graphicsData) {
GL2 gl = graphicsData.getGlContext();
- textRenderer.initialize(gl);
+ textRenderer.setSmoothing(false);
}
@Override
@@ -43,6 +49,9 @@
String text;
+ textRenderer.setColor(Color.BLACK);
+ textRenderer.begin3DRendering();
+
for (View<CyNode> nodeView : networkView.getNodeViews()) {
x =
nodeView.getVisualProperty(RichVisualLexicon.NODE_X_LOCATION)
.floatValue() / distanceScale;
@@ -54,25 +63,49 @@
// Draw it only if the visual property says it is
visible
if
(nodeView.getVisualProperty(MinimalVisualLexicon.NODE_VISIBLE)) {
gl.glPushMatrix();
- gl.glTranslatef(x, y, z);
+// gl.glTranslatef(x, y, z);
gl.glColor3f(0.2f, 0.2f, 0.2f);
text =
nodeView.getVisualProperty(MinimalVisualLexicon.NODE_LABEL);
- gl.glTranslatef((float) TEXT_OFFSET.x(),
- (float) TEXT_OFFSET.y(),
- (float) TEXT_OFFSET.z());
+// gl.glTranslatef((float) TEXT_OFFSET.x(),
+// (float) TEXT_OFFSET.y(),
+// (float) TEXT_OFFSET.z());
if (text != null) {
- gl.glScalef(TEXT_SCALE, TEXT_SCALE,
TEXT_SCALE);
+
+// gl.glScalef(TEXT_SCALE, TEXT_SCALE,
TEXT_SCALE);
// textRenderer.drawCenteredText(gl,
text, TEXT_OFFSET);
// textRenderer.drawCenteredText(gl,
"aac");
+
+// text = "test" + nodeView.getSUID();
+ textRenderer.draw3D(text,
+ x + (float)
TEXT_OFFSET.x() - text.length() * 0.0085f,
+ y + (float)
TEXT_OFFSET.y(),
+ z + (float)
TEXT_OFFSET.z(),
+ 0.0005f);
}
gl.glPopMatrix();
}
}
+
+ textRenderer.flush();
+ textRenderer.endRendering();
+
}
+ private int getStringWidth(TextRenderer textRenderer, String string) {
+// FontRenderContext renderContext =
textRenderer.getFontRenderContext();
+
+ int width = 0;
+
+ for (int i = 0; i < string.length(); i++) {
+ width += textRenderer.getCharWidth(string.charAt(i));
+
+ }
+
+ return width;
+ }
}
Copied:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/StringRenderer.java
(from rev 28070,
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/TextRenderer.java)
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/StringRenderer.java
(rev 0)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/StringRenderer.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -0,0 +1,143 @@
+package org.cytoscape.paperwing.internal.rendering.text;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.media.opengl.GL2;
+import org.cytoscape.paperwing.internal.geometric.Vector3;
+
+public class StringRenderer {
+
+ private static final float CHARACTER_SPACING = 0.1f;
+
+ private static final float MAX_CHARACTER_HEIGHT = 1.0f;
+ private static final float MAX_CHARACTER_SECONDARY_HEIGHT = 0.5f;
+ private static final float MAX_CHARACTER_WIDTH = 0.5f;
+
+ Map<Character, RenderedCharacter> characterLists;
+
+ private class RenderedCharacter {
+ int characterListIndex;
+ float width;
+ char character;
+
+ @Override
+ public String toString() {
+ return ("RenderedCharacter " + character);
+ }
+ }
+
+ public StringRenderer() {
+ characterLists = new HashMap(80);
+ }
+
+ public void initialize(GL2 gl) {
+ initializeCharacterSet(gl);
+
+ initializeCharacterLists(gl);
+
+ // System.out.println(characterLists);
+ }
+
+ private void initializeCharacterSet(GL2 gl) {
+ int startingIndex;
+ startingIndex = gl.glGenLists(26);
+ char startingCharacter = 'a';
+
+ RenderedCharacter renderedCharacter;
+
+ for (int i = 0; i < 26; i++) {
+ renderedCharacter = new RenderedCharacter();
+ renderedCharacter.character = startingCharacter++;
+ renderedCharacter.characterListIndex = startingIndex++;
+
+ characterLists.put(renderedCharacter.character,
renderedCharacter);
+ }
+ }
+
+ private void initializeCharacterLists(GL2 gl) {
+ int listIndex;
+
+ float maxHeight = 1.0f;
+ float secondaryHeight = 0.5f;
+ float maxWidth = 0.5f;
+
+ for (RenderedCharacter renderedCharacter :
characterLists.values()) {
+ listIndex = renderedCharacter.characterListIndex;
+ renderedCharacter.width = maxWidth;
+
+ gl.glNewList(listIndex, GL2.GL_COMPILE);
+ gl.glBegin(GL2.GL_LINE_STRIP);
+
+ // Characters are drawn with bottom left as origin,
extends to (1, 0.5)
+
+ switch (renderedCharacter.character) {
+ case 'a':
+ gl.glVertex2f(maxWidth, secondaryHeight * 0.0f);
+ gl.glVertex2f(maxWidth, secondaryHeight * 0.9f);
+ gl.glVertex2f(maxWidth * 0.9f, secondaryHeight);
+ gl.glVertex2f(maxWidth * 0.2f, secondaryHeight);
+ gl.glVertex2f(maxWidth * 0.1f, secondaryHeight
* 0.7f);
+ gl.glVertex2f(maxWidth * 0.05f, secondaryHeight
* 0.0f);
+ gl.glVertex2f(maxWidth, secondaryHeight * 0.1f);
+ break;
+ case 'c':
+ gl.glVertex2f(maxWidth, secondaryHeight);
+ gl.glVertex2f(maxWidth * 0.1f, secondaryHeight);
+ gl.glVertex2f(maxWidth * 0.1f, secondaryHeight
* 0.0f);
+ gl.glVertex2f(maxWidth, secondaryHeight * 0.0f);
+ break;
+ }
+
+ gl.glEnd();
+ gl.glEndList();
+
+
+ }
+ }
+
+ private void drawString(GL2 gl, String text) {
+ char current;
+ RenderedCharacter renderedCharacter;
+
+ for (int i = 0; i < text.length(); i++) {
+ current = text.charAt(i);
+
+ renderedCharacter = characterLists.get(current);
+
+// System.out.println("get result for " + current + "in "
+ text + ": " + renderedCharacter);
+
+ if (renderedCharacter != null) {
+
gl.glCallList(renderedCharacter.characterListIndex);
+// System.out.println("calling list for :" +
renderedCharacter.character);
+ gl.glTranslatef(renderedCharacter.width +
CHARACTER_SPACING, 0, 0);
+ }
+ }
+ }
+
+ public void drawCenteredText(GL2 gl, String text) {
+ float stringWidth = 0;
+
+ char current;
+ RenderedCharacter renderedCharacter;
+
+ for (int i = 0; i < text.length(); i++) {
+ current = text.charAt(i);
+
+ renderedCharacter = characterLists.get(current);
+
+ if (renderedCharacter != null) {
+ stringWidth += renderedCharacter.width;
+ }
+ }
+
+ gl.glDisable(GL2.GL_LIGHTING);
+ gl.glPushMatrix();
+
+ gl.glTranslatef(-stringWidth / 2, 0, 0);
+ drawString(gl, text);
+
+ gl.glPopMatrix();
+ gl.glEnable(GL2.GL_LIGHTING);
+ }
+}
Property changes on:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/StringRenderer.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/TextRenderer.java
===================================================================
---
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/TextRenderer.java
2012-01-23 22:04:00 UTC (rev 28075)
+++
csplugins/trunk/toronto/yuedong/paperwing-impl/src/main/java/org/cytoscape/paperwing/internal/rendering/text/TextRenderer.java
2012-01-23 22:23:27 UTC (rev 28076)
@@ -1,143 +0,0 @@
-package org.cytoscape.paperwing.internal.rendering.text;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.media.opengl.GL2;
-import org.cytoscape.paperwing.internal.geometric.Vector3;
-
-public class TextRenderer {
-
- private static final float CHARACTER_SPACING = 0.1f;
-
- private static final float MAX_CHARACTER_HEIGHT = 1.0f;
- private static final float MAX_CHARACTER_SECONDARY_HEIGHT = 0.5f;
- private static final float MAX_CHARACTER_WIDTH = 0.5f;
-
- Map<Character, RenderedCharacter> characterLists;
-
- private class RenderedCharacter {
- int characterListIndex;
- float width;
- char character;
-
- @Override
- public String toString() {
- return ("RenderedCharacter " + character);
- }
- }
-
- public TextRenderer() {
- characterLists = new HashMap(80);
- }
-
- public void initialize(GL2 gl) {
- initializeCharacterSet(gl);
-
- initializeCharacterLists(gl);
-
- // System.out.println(characterLists);
- }
-
- private void initializeCharacterSet(GL2 gl) {
- int startingIndex;
- startingIndex = gl.glGenLists(26);
- char startingCharacter = 'a';
-
- RenderedCharacter renderedCharacter;
-
- for (int i = 0; i < 26; i++) {
- renderedCharacter = new RenderedCharacter();
- renderedCharacter.character = startingCharacter++;
- renderedCharacter.characterListIndex = startingIndex++;
-
- characterLists.put(renderedCharacter.character,
renderedCharacter);
- }
- }
-
- private void initializeCharacterLists(GL2 gl) {
- int listIndex;
-
- float maxHeight = 1.0f;
- float secondaryHeight = 0.5f;
- float maxWidth = 0.5f;
-
- for (RenderedCharacter renderedCharacter :
characterLists.values()) {
- listIndex = renderedCharacter.characterListIndex;
- renderedCharacter.width = maxWidth;
-
- gl.glNewList(listIndex, GL2.GL_COMPILE);
- gl.glBegin(GL2.GL_LINE_STRIP);
-
- // Characters are drawn with bottom left as origin,
extends to (1, 0.5)
-
- switch (renderedCharacter.character) {
- case 'a':
- gl.glVertex2f(maxWidth, secondaryHeight * 0.0f);
- gl.glVertex2f(maxWidth, secondaryHeight * 0.9f);
- gl.glVertex2f(maxWidth * 0.9f, secondaryHeight);
- gl.glVertex2f(maxWidth * 0.2f, secondaryHeight);
- gl.glVertex2f(maxWidth * 0.1f, secondaryHeight
* 0.7f);
- gl.glVertex2f(maxWidth * 0.05f, secondaryHeight
* 0.0f);
- gl.glVertex2f(maxWidth, secondaryHeight * 0.1f);
- break;
- case 'c':
- gl.glVertex2f(maxWidth, secondaryHeight);
- gl.glVertex2f(maxWidth * 0.1f, secondaryHeight);
- gl.glVertex2f(maxWidth * 0.1f, secondaryHeight
* 0.0f);
- gl.glVertex2f(maxWidth, secondaryHeight * 0.0f);
- break;
- }
-
- gl.glEnd();
- gl.glEndList();
-
-
- }
- }
-
- private void drawString(GL2 gl, String text) {
- char current;
- RenderedCharacter renderedCharacter;
-
- for (int i = 0; i < text.length(); i++) {
- current = text.charAt(i);
-
- renderedCharacter = characterLists.get(current);
-
-// System.out.println("get result for " + current + "in "
+ text + ": " + renderedCharacter);
-
- if (renderedCharacter != null) {
-
gl.glCallList(renderedCharacter.characterListIndex);
-// System.out.println("calling list for :" +
renderedCharacter.character);
- gl.glTranslatef(renderedCharacter.width +
CHARACTER_SPACING, 0, 0);
- }
- }
- }
-
- public void drawCenteredText(GL2 gl, String text) {
- float stringWidth = 0;
-
- char current;
- RenderedCharacter renderedCharacter;
-
- for (int i = 0; i < text.length(); i++) {
- current = text.charAt(i);
-
- renderedCharacter = characterLists.get(current);
-
- if (renderedCharacter != null) {
- stringWidth += renderedCharacter.width;
- }
- }
-
- gl.glDisable(GL2.GL_LIGHTING);
- gl.glPushMatrix();
-
- gl.glTranslatef(-stringWidth / 2, 0, 0);
- drawString(gl, text);
-
- gl.glPopMatrix();
- gl.glEnable(GL2.GL_LIGHTING);
- }
-}
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.