protected void drawToolTipOutline( DrawContext dc, double width, double height, ToolTipAttributes attributes) { GL2 gl = dc.getGL().getGL2(); // GL initialization checks for GL2 compatibility. this.applyColor(dc, attributes.getOutlineColor(), attributes.getOutlineOpacity()); gl.glLineWidth((float) getOutlineWidth()); // Draw a line loop around the background rectangle. Inset the lines slightly to compensate for // OpenGL's line // rasterization algorithm. We want the line to straddle the rectangle pixels. double inset = 0.5; gl.glBegin(GL2.GL_LINE_LOOP); gl.glVertex2d(inset, inset); gl.glVertex2d(width - inset, inset); gl.glVertex2d(width - inset, height - inset); gl.glVertex2d(inset, height - inset); gl.glEnd(); }
private void recursiveDraw( int level, double x1, double y1, double x2, double y2, double x3, double y3) { if (level < 1) { return; } gl.glBegin(GL2.GL_LINE_LOOP); gl.glVertex2d(x1, y1); gl.glVertex2d(x2, y2); gl.glVertex2d(x3, y3); gl.glEnd(); for (int i = 0; i < transitions; i += 1) { x1 = rotate_scale_xx[i] * x1 + rotate_scale_xy[i] * y1 + trans_x[i]; y1 = rotate_scale_yx[i] * x1 + rotate_scale_yy[i] * y1 + trans_y[i]; x2 = rotate_scale_xx[i] * x2 + rotate_scale_xy[i] * y2 + trans_x[i]; y2 = rotate_scale_yx[i] * x2 + rotate_scale_yy[i] * y2 + trans_y[i]; x3 = rotate_scale_xx[i] * x3 + rotate_scale_xy[i] * y3 + trans_x[i]; y3 = rotate_scale_yx[i] * x3 + rotate_scale_yy[i] * y3 + trans_y[i]; recursiveDraw(level - 1, x1, y1, x2, y2, x3, y3); } }
public void draw() { // Clear GL state gl.glDisable(GL_LIGHTING); gl.glDisable(GL_DEPTH); gl.glMatrixMode(GL_MODELVIEW); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glMatrixMode(GL_PROJECTION); gl.glPushMatrix(); gl.glLoadIdentity(); gl.glClearColor(0.8f, 0.2f, 0.2f, 1.0f); gl.glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); gl.glPointSize(1.0f); // Set the viewport glu.gluOrtho2D(xMin, xMax, yMin, yMax); gl.glBegin(GL_POINTS); for (int x = (int) (xMin); x < xMax; x++) for (int y = (int) (yMin); y < yMax; y++) { gl.glColor3d(viewPort[x][y].r, viewPort[x][y].g, viewPort[x][y].b); gl.glVertex2d(x + 0.5, y + 0.5); } gl.glEnd(); // Restore state gl.glMatrixMode(GL_MODELVIEW); gl.glPopMatrix(); gl.glMatrixMode(GL_PROJECTION); gl.glPopMatrix(); gl.glEnable(GL_LIGHTING); gl.glEnable(GL_DEPTH); }