Skip to content
This repository has been archived by the owner on Jun 26, 2018. It is now read-only.

Commit

Permalink
Merge branch 'develop' of git@github.com:Caleydo/caleydo-dev.git into…
Browse files Browse the repository at this point in the history
… develop_t
  • Loading branch information
sgratzl committed Dec 12, 2013
2 parents 5e906b0 + ad79a7c commit bd8dcf3
Show file tree
Hide file tree
Showing 19 changed files with 528 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ public GLGraphics color(float[] rgba) {
return color(rgba[0], rgba[1], rgba[2], rgba[3]);
}


public GLGraphics textColor(Color color) {
text.setColor(color);
local.getText_bold().setColor(color);
Expand Down Expand Up @@ -327,6 +326,15 @@ public GLGraphics renderRect(boolean fill, float x, float y, float w, float h) {
return this;
}

public GLGraphics drawPoint(float x, float y) {
if (isInvalid(x) || isInvalid(y))
return this;
gl.glBegin(GL.GL_POINTS);
gl.glVertex3f(x, y, z);
gl.glEnd();
return this;
}

public GLGraphics fillRoundedRect(float x, float y, float w, float h, float radius) {
int segments;
if (radius < 4)
Expand Down Expand Up @@ -725,8 +733,7 @@ public GLGraphics move(Vec2f xy) {
}

/**
* shortcut to {@link GL2#glTranslatef(float, float, float)
* shortcut to {@link GL2#glTranslatef(float, float, float)
*/
public GLGraphics move(float x, float y) {
if (x != 0 || y != 0)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
/*******************************************************************************
* Caleydo - Visualization for Molecular Biology - http://caleydo.org
* Copyright (c) The Caleydo Team. All rights reserved.
* Licensed under the new BSD license, available at http://caleydo.org/license
*******************************************************************************/
package org.caleydo.core.view.opengl.layout2.geom;

import gleem.linalg.Vec2f;

import java.awt.geom.Line2D;

/**
* a custom implementation of a line to avoid awt
*
* @author Christian
*
*/
public class Line implements Cloneable {
private float x1, y1, x2, y2;

public Line() {

}

public Line(float x1, float y1, float x2, float y2) {
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}

public Line(Vec2f point1, Vec2f point2) {
this(point1.x(), point1.y(), point2.x(), point2.y());
}

public float x1() {
return x1;
}

public float x2() {
return x2;
}

public float y1() {
return y1;
}

public float y2() {
return y2;
}

public Line x1(float x1) {
this.x1 = x1;
return this;
}

public Line x2(float x2) {
this.x2 = x2;
return this;
}

public Line y1(float y1) {
this.y1 = y1;
return this;
}

public Line y2(float y2) {
this.y2 = y2;
return this;
}

public Vec2f point1() {
return new Vec2f(x1, y1);
}

public Vec2f point2() {
return new Vec2f(x2, y2);
}

public Line point1(float x1, float y1) {
this.x1 = x1;
this.y1 = y1;
return this;
}

public Line point2(float x2, float y2) {
this.x2 = x2;
this.y2 = y2;
return this;
}

public Line point1(Vec2f point1) {
this.x1 = point1.x();
this.y1 = point1.y();
return this;
}

public Line point2(Vec2f point2) {
this.x2 = point2.x();
this.y2 = point2.y();
return this;
}

public Line2D asLine2D() {
return new Line2D.Float(x1, y1, x2, y2);
}


@Override
public Rect clone() {
try {
return (Rect) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException();
}
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Float.floatToIntBits(x1);
result = prime * result + Float.floatToIntBits(x2);
result = prime * result + Float.floatToIntBits(y1);
result = prime * result + Float.floatToIntBits(y2);
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Line other = (Line) obj;
if (Float.floatToIntBits(x1) != Float.floatToIntBits(other.x1))
return false;
if (Float.floatToIntBits(x2) != Float.floatToIntBits(other.x2))
return false;
if (Float.floatToIntBits(y1) != Float.floatToIntBits(other.y1))
return false;
if (Float.floatToIntBits(y2) != Float.floatToIntBits(other.y2))
return false;
return true;
}

@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Line(").append(x1).append(',');
builder.append(y1).append(',');
builder.append(x2).append(',');
builder.append(y2).append(')');
return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ public interface IPathwayRepresentation {
*/
public List<Rect> getVertexRepsBounds(PathwayVertexRep vertexRep);

/**
* Gets the bounds of the whole pathway representation as rectangle. The coordinates are specified in pixels with
* the origin of the coordinate system at the left top.
*
* @return The bounds of the pathway representation.
*/
public Rect getPathwayBounds();

/**
* Adds the specified context menu item to the context menu of all vertexReps in this pathway. The selected
* vertexRep is set in the item using {@link VertexRepBasedContextMenuItem#setVertexRep(PathwayVertexRep)}.
Expand Down
59 changes: 29 additions & 30 deletions org.caleydo.util.bubblesets/src/setvis/BubbleSetGLRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.PixelGrabber;
import java.util.ArrayList;
import java.util.List;

import javax.media.opengl.GL2;
Expand Down Expand Up @@ -68,11 +67,11 @@ void setOutlineThickness(int thickness, boolean selection){
outlineThicknessSelection=thickness;
}

public void addToLastGroup(ArrayList<Rectangle2D> items, ArrayList<Line2D> edges){
public void addToLastGroup(List<Rectangle2D> items, List<Line2D> edges) {
addToGroup(items, edges, numberOfGroups);
}

public void addToGroup(ArrayList<Rectangle2D> items, ArrayList<Line2D> edges, int groupID){
public void addToGroup(List<Rectangle2D> items, List<Line2D> edges, int groupID) {
// add items
for(Rectangle2D node : items){
bubblesetCanvas.addItem(numberOfGroups, node.getMinX(), node.getMinY(), node.getWidth(), node.getHeight());
Expand All @@ -85,7 +84,7 @@ public void addToGroup(ArrayList<Rectangle2D> items, ArrayList<Line2D> edges, in
}
}

public int addGroup(ArrayList<Rectangle2D> items, ArrayList<Line2D> edges, Color colorValue){
public int addGroup(List<Rectangle2D> items, List<Line2D> edges, Color colorValue) {
if(items==null)
return -1;

Expand Down Expand Up @@ -137,32 +136,32 @@ public void setSize(int width, int height){
texRenderer.setSize(width,height);
}

public void renderPxl(GL2 gl, float pxlWidth, float pxlHeight, float opacity)
{
texRenderer.setColor(1.0f, 1.0f, 1.0f, opacity);
bubbleSetsTexture = texRenderer.getTexture();

gl.glEnable(GL2.GL_BLEND);
gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA);

bubbleSetsTexture.enable(gl);
bubbleSetsTexture.bind(gl);
gl.glBegin(GL2.GL_QUADS);
gl.glTexCoord2f(0, 0);
gl.glVertex3f(0.0f, 0.0f, 0.0f);

gl.glTexCoord2f(1, 0);
gl.glVertex3f(pxlWidth, 0.0f, 0.0f);

gl.glTexCoord2f(1, 1);
gl.glVertex3f(pxlWidth, pxlHeight, 0.0f);

gl.glTexCoord2f(0, 1);
gl.glVertex3f(0.0f, pxlHeight, 0.0f);
gl.glEnd();
bubbleSetsTexture.disable(gl);
//gl.glDisable(GL2.GL_BLEND);
}
// public void renderPxl(GL2 gl, float pxlWidth, float pxlHeight, float opacity)
// {
// texRenderer.setColor(1.0f, 1.0f, 1.0f, opacity);
// bubbleSetsTexture = texRenderer.getTexture();
//
// gl.glEnable(GL2.GL_BLEND);
// gl.glBlendFunc(GL2.GL_ONE, GL2.GL_ONE_MINUS_SRC_ALPHA);
//
// bubbleSetsTexture.enable(gl);
// bubbleSetsTexture.bind(gl);
// gl.glBegin(GL2.GL_QUADS);
// gl.glTexCoord2f(0, 0);
// gl.glVertex3f(0.0f, 0.0f, 0.0f);
//
// gl.glTexCoord2f(1, 0);
// gl.glVertex3f(pxlWidth, 0.0f, 0.0f);
//
// gl.glTexCoord2f(1, 1);
// gl.glVertex3f(pxlWidth, pxlHeight, 0.0f);
//
// gl.glTexCoord2f(0, 1);
// gl.glVertex3f(0.0f, pxlHeight, 0.0f);
// gl.glEnd();
// bubbleSetsTexture.disable(gl);
// //gl.glDisable(GL2.GL_BLEND);
// }

public void renderPxl(GL2 gl, float pxlWidth, float pxlHeight)
{
Expand Down
39 changes: 39 additions & 0 deletions org.caleydo.util.bubblesets/src/setvis/gui/CanvasComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*/
package setvis.gui;

import gleem.linalg.Vec2f;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
Expand All @@ -24,6 +26,7 @@
import java.util.LinkedList;
import java.util.List;

import javax.media.opengl.glu.GLUtessellator;
import javax.swing.JComponent;

import org.caleydo.core.data.selection.SelectionType;
Expand Down Expand Up @@ -94,6 +97,8 @@ private Position(final int groupID, final Rectangle2D rect) {
private final List<Integer> outlineThickness;
private final List<Boolean> isVisibleList;

protected GLUtessellator tobj;

/**
* The mouse and mouse motion listener for the interaction.
*/
Expand Down Expand Up @@ -513,6 +518,15 @@ public void removeCurrentGroup() {
--curItemGroup;
}

public void removeAllGroups() {
int numberOfGroups = getGroupCount() - 1;
while (getGroupCount() > 0) {
setCurrentGroup(numberOfGroups);
removeCurrentGroup();
numberOfGroups--;
}
}

@Override
public void setCurrentGroup(final int curItemGroup) {
this.curItemGroup = curItemGroup;
Expand Down Expand Up @@ -873,6 +887,31 @@ public void paint(final Graphics gfx) {
// }
}

public List<Vec2f> getShapePoints(final Graphics gfx) {
if (groupShapes == null) {
// the cache needs to be recreated
final AbstractShapeGenerator shaping = new ShapeSimplifier(shaper, simplifyTolerance);
groupShapes = shaping.createShapesForLists(items, edges);
}

final Shape gs = groupShapes[selectionID];
AffineTransform tf = new AffineTransform();
PathIterator pi = gs.getPathIterator(tf);
float[] position = new float[6];
int type = -1;
List<Vec2f> points = new ArrayList<>();

if (gs != null) {
while (!pi.isDone() && type != PathIterator.SEG_CLOSE) {
pi.next();
type = pi.currentSegment(position);
points.add(new Vec2f(position[0], position[1]));
}
}

return points;
}

// whether to draw points
private boolean drawPoints;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1009,4 +1009,11 @@ public void addVertexRepSelectionListener(IVertexRepSelectionListener listener)

}

@Override
public Rect getPathwayBounds() {

return new Rect(0, 0, pixelGLConverter.getPixelWidthForGLWidth(viewFrustum.getWidth()),
pixelGLConverter.getPixelHeightForGLHeight(viewFrustum.getHeight()));
}

}
Loading

0 comments on commit bd8dcf3

Please sign in to comment.