bugged
stringlengths 6
599k
| fixed
stringlengths 10
599k
| __index_level_0__
int64 0
1.13M
|
|---|---|---|
public boolean contains(JComponent c, int x, int y) { if (path == null) { return false; } else { Point loc = relationship.getLocation(); return path.intersects(x - radius + loc.x, y - radius + loc.y, radius*2, radius*2); } }
|
public boolean contains(JComponent c, int x, int y) { if (path == null) { return false; } else { Point loc = relationship.getLocation(); return path.intersects(x - radius + loc.x, y - radius + loc.y, radius*2, radius*2); } }
| 1,111,536
|
public boolean intersects(Rectangle region) { return path.intersects(region.x, region.y, region.width, region.height); }
|
public boolean intersects(Rectangle region) { return containmentPath.intersects(region.x, region.y, region.width, region.height); }
| 1,111,537
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,538
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,539
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,540
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,541
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,542
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,543
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,544
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); containmentPath.lineTo(end.x, start.y); containmentPath.moveTo(start.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start containmentPath.lineTo(end.x, start.y); containmentPath.moveTo(start.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,545
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,546
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); containmentPath.lineTo(start.x, end.y); containmentPath.moveTo(start.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start containmentPath.lineTo(start.x, end.y); containmentPath.moveTo(start.x, start.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,547
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
|
public void paint(Graphics g, JComponent c) { logger.debug("BasicRelationshipUI is painting"); Relationship r = (Relationship) c; Graphics2D g2 = (Graphics2D) g; g2.translate(c.getX() * -1, c.getY() * -1); // playpen coordinate space if (logger.isDebugEnabled()) { g2.setColor(c.getBackground()); Rectangle bounds = c.getBounds(); g2.fillRect(bounds.x, bounds.y, bounds.width, bounds.height); g2.setColor(c.getForeground()); } try { Point pktloc = pkConnectionPoint; Point start = new Point(pktloc.x + r.getPkTable().getLocation().x, pktloc.y + r.getPkTable().getLocation().y); Point fktloc = fkConnectionPoint; Point end = new Point(fktloc.x + r.getFkTable().getLocation().x, fktloc.y + r.getFkTable().getLocation().y); // XXX: could optimise by checking if PK or FK tables have moved if (path == null) { path = new GeneralPath(GeneralPath.WIND_NON_ZERO, 5); } else { path.reset(); } if (relationship.getPkTable() == relationship.getFkTable()) { // special case hack for self-referencing table // assume orientation is PARENT_FACES_BOTTOM | CHILD_FACES_LEFT path.moveTo(start.x, start.y); path.lineTo(start.x, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, start.y + getTerminationLength() * 2); path.lineTo(end.x - getTerminationLength() * 2, end.y); path.lineTo(end.x, end.y); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0 && (orientation & (CHILD_FACES_LEFT | CHILD_FACES_RIGHT)) != 0) { int midx = (Math.abs(end.x - start.x) / 2) + Math.min(start.x, end.x); path.moveTo(start.x, start.y); path.lineTo(midx, start.y); path.lineTo(midx, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(midx, end.y); path.lineTo(midx, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0 && (orientation & (CHILD_FACES_TOP | CHILD_FACES_BOTTOM)) != 0) { int midy = (Math.abs(end.y - start.y) / 2) + Math.min(start.y, end.y); path.moveTo(start.x, start.y); path.lineTo(start.x, midy); path.lineTo(end.x, midy); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, midy); path.lineTo(start.x, midy); } else if ( (orientation & (PARENT_FACES_LEFT | PARENT_FACES_RIGHT)) != 0) { path.moveTo(start.x, start.y); path.lineTo(end.x, start.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(end.x, start.y); } else if ( (orientation & (PARENT_FACES_TOP | PARENT_FACES_BOTTOM)) != 0) { path.moveTo(start.x, start.y); path.lineTo(start.x, end.y); path.lineTo(end.x, end.y); // now retrace our steps so the shape doesn't autoclose with a straight line from finish to start path.lineTo(start.x, end.y); } else { // unknown case: draw straight line. path.moveTo(start.x, start.y); path.lineTo(end.x, end.y); } if (r.isSelected()) { g2.setColor(selectedColor); } else { g2.setColor(unselectedColor); } Stroke oldStroke = g2.getStroke(); if (relationship.getModel().isIdentifying()) { g2.setStroke(getIdentifyingStroke()); } else { g2.setStroke(getNonIdentifyingStroke()); } g2.draw(path); if (logger.isDebugEnabled()) logger.debug("Drew path "+path); g2.setStroke(oldStroke); paintTerminations(g2, start, end, orientation); } finally { g2.translate(c.getX(), c.getY()); // playpen coordinate space } }
| 1,111,548
|
public String generateToolTip(XYDataset dataset, int series, int item){ return (String)info[series].get(new Double(dataset.getXValue(series,item))); }
|
public String generateToolTip(XYDataset dataset, int series, int item){ return (String)info[seriesKeys[series]-1].get(new Double(dataset.getXValue(series,item))); }
| 1,111,549
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
|
protected void handleException(JellyException e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
| 1,111,551
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
| 1,111,552
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
| 1,111,553
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } throw new JellyException(e, fileName, elementName, columnNumber, lineNumber); }
|
protected void handleException(Exception e) throws Exception { log.error( "Caught exception: " + e, e ); if ( e instanceof JellyException ) { e.fillInStackTrace(); throw e; } if ( e instanceof InvocationTargetException) { throw new JellyException( ((InvocationTargetException)e).getTargetException(), fileName, elementName, columnNumber, lineNumber ); } if ( e.getElementName() == null ) { e.setElementName( elementName ); } throw e; }
| 1,111,554
|
public void mousePressed(MouseEvent evt) { requestFocus(); maybeShowPopup(evt); Point p = evt.getPoint(); unzoomPoint(p); PlayPenComponent c = contentPane.getComponentAt(p); if (c != null) p.translate(-c.getX(), -c.getY()); if (c instanceof Relationship) { if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // selection Relationship r = (Relationship) c; PlayPen pp = (PlayPen) r.getPlayPen(); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } r.setSelected(true); // moving pk/fk decoration boolean overPkDec = ((RelationshipUI) r.getUI()).isOverPkDecoration(p); if (overPkDec || ((RelationshipUI) r.getUI()).isOverFkDecoration(p)) { new RelationshipDecorationMover(r, overPkDec); } } } else if (c instanceof TablePane) { evt.getComponent().requestFocus(); TablePane tp = (TablePane) c; // make sure it was a left click? if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // dragging try { PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(p); logger.debug("MP: clickCol="+clickCol+",columnsSize="+tp.getModel().getColumns().size()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { // 1. unconditionally de-select everything if this table is unselected // 2. if the table was selected, de-select everything if the click was not on the // column header of the table if (!tp.isSelected() || (clickCol > TablePane.COLUMN_INDEX_TITLE && clickCol < tp.getModel().getColumns().size()) ) { pp.selectNone(); } } // re-select the table pane (fire new selection event when appropriate) tp.setSelected(true); // de-select columns if shift and ctrl were not pressed if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { tp.selectNone(); } // select current column unconditionally if (clickCol < tp.getModel().getColumns().size()) { tp.selectColumn(clickCol); } // handle drag (but not if createRelationshipAction is active!) logger.debug("(mouse pressed) click col is: " + clickCol + ", column index title is: " + TablePane.COLUMN_INDEX_TITLE); logger.debug("(mouse pressed) create relationship is active: " + ArchitectFrame.getMainInstance().createRelationshipIsActive()); if (clickCol == TablePane.COLUMN_INDEX_TITLE && !ArchitectFrame.getMainInstance().createRelationshipIsActive()) { Iterator it = pp.getSelectedTables().iterator(); logger.debug("event point: " + p); logger.debug("zoomed event point: " + pp.zoomPoint(new Point(p))); while (it.hasNext()) { // create FloatingTableListener for each selected item TablePane t3 = (TablePane)it.next(); logger.debug("(" + t3.getModel().getName() + ") zoomed selected table point: " + t3.getLocationOnScreen()); logger.debug("(" + t3.getModel().getName() + ") unzoomed selected table point: " + pp.unzoomPoint(t3.getLocationOnScreen())); /* the floating table listener expects zoomed handles which are relative to the location of the table column which was clicked on. */ Point clickedColumn = tp.getLocationOnScreen(); Point otherTable = t3.getLocationOnScreen(); Point handle = pp.zoomPoint(new Point(p)); logger.debug("(" + t3.getModel().getName() + ") translation x=" + (otherTable.getX() - clickedColumn.getX()) + ",y=" + (otherTable.getY() - clickedColumn.getY())); handle.translate((int)(clickedColumn.getX() - otherTable.getX()), (int) (clickedColumn.getY() - otherTable.getY())); new PlayPen.FloatingTableListener(pp, t3, handle,false); } } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } else { if ((evt.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0) { selectNone(); rubberBandOrigin = new Point(p); rubberBand = new Rectangle(rubberBandOrigin.x, rubberBandOrigin.y, 0, 0); } } }
|
public void mousePressed(MouseEvent evt) { requestFocus(); maybeShowPopup(evt); Point p = evt.getPoint(); unzoomPoint(p); PlayPenComponent c = contentPane.getComponentAt(p); if (c != null) p.translate(-c.getX(), -c.getY()); if (c instanceof Relationship) { if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // selection Relationship r = (Relationship) c; PlayPen pp = (PlayPen) r.getPlayPen(); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { pp.selectNone(); } r.setSelected(true); // moving pk/fk decoration boolean overPkDec = ((RelationshipUI) r.getUI()).isOverPkDecoration(p); if (overPkDec || ((RelationshipUI) r.getUI()).isOverFkDecoration(p)) { new RelationshipDecorationMover(r, overPkDec); } } } else if (c instanceof TablePane) { evt.getComponent().requestFocus(); TablePane tp = (TablePane) c; // make sure it was a left click? if ((evt.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 0) { // dragging try { PlayPen pp = (PlayPen) tp.getPlayPen(); int clickCol = tp.pointToColumnIndex(p); logger.debug("MP: clickCol="+clickCol+",columnsSize="+tp.getModel().getColumns().size()); if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { // 1. unconditionally de-select everything if this table is unselected // 2. if the table was selected, de-select everything if the click was not on the // column header of the table if (!tp.isSelected() || (clickCol > TablePane.COLUMN_INDEX_TITLE && clickCol < tp.getModel().getColumns().size()) ) { pp.selectNone(); } } // re-select the table pane (fire new selection event when appropriate) tp.setSelected(true); // de-select columns if shift and ctrl were not pressed if ( (evt.getModifiersEx() & (InputEvent.SHIFT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK)) == 0) { tp.selectNone(); } // select current column unconditionally if (clickCol < tp.getModel().getColumns().size()) { tp.selectColumn(clickCol); } // handle drag (but not if createRelationshipAction is active!) logger.debug("(mouse pressed) click col is: " + clickCol + ", column index title is: " + TablePane.COLUMN_INDEX_TITLE); logger.debug("(mouse pressed) create relationship is active: " + ArchitectFrame.getMainInstance().createRelationshipIsActive()); if (clickCol == TablePane.COLUMN_INDEX_TITLE && !ArchitectFrame.getMainInstance().createRelationshipIsActive()) { Iterator it = pp.getSelectedTables().iterator(); logger.debug("event point: " + p); logger.debug("zoomed event point: " + pp.zoomPoint(new Point(p))); while (it.hasNext()) { // create FloatingTableListener for each selected item TablePane t3 = (TablePane)it.next(); logger.debug("(" + t3.getModel().getName() + ") zoomed selected table point: " + t3.getLocationOnScreen()); logger.debug("(" + t3.getModel().getName() + ") unzoomed selected table point: " + pp.unzoomPoint(t3.getLocationOnScreen())); /* the floating table listener expects zoomed handles which are relative to the location of the table column which was clicked on. */ Point clickedColumn = tp.getLocationOnScreen(); Point otherTable = t3.getLocationOnScreen(); Point handle = pp.zoomPoint(new Point(p)); logger.debug("(" + t3.getModel().getName() + ") translation x=" + (otherTable.getX() - clickedColumn.getX()) + ",y=" + (otherTable.getY() - clickedColumn.getY())); handle.translate((int)(clickedColumn.getX() - otherTable.getX()), (int) (clickedColumn.getY() - otherTable.getY())); new PlayPen.FloatingTableListener(pp, t3, handle,false); } } } catch (ArchitectException e) { logger.error("Exception converting point to column", e); } } maybeShowPopup(evt); } else { if ((evt.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) != 0 && !evt.isPopupTrigger()) { selectNone(); rubberBandOrigin = new Point(p); rubberBand = new Rectangle(rubberBandOrigin.x, rubberBandOrigin.y, 0, 0); } } }
| 1,111,555
|
protected void createUI() { GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.insets = new Insets( 2, 20, 2, 2 ); labelConstraints.anchor = GridBagConstraints.EAST; labelConstraints.gridwidth = GridBagConstraints.RELATIVE; //next-to-last labelConstraints.fill = GridBagConstraints.NONE; //reset to default labelConstraints.weightx = 0.0; //reset to default GridBagConstraints fieldConstraints = new GridBagConstraints(); fieldConstraints.insets = new Insets( 2, 2, 2, 20 ); fieldConstraints.anchor = GridBagConstraints.WEST; fieldConstraints.gridwidth = GridBagConstraints.REMAINDER; //end row fieldConstraints.weightx = 1.0; JPanel loginPane = new JPanel(); GridBagLayout gb = new GridBagLayout(); loginPane.setLayout( gb ); JLabel idLabel = new JLabel( "Username" ); labelConstraints.insets = new Insets( 20, 20, 4, 4 ); gb.setConstraints( idLabel, labelConstraints ); loginPane.add( idLabel ); idField = new JTextField( 15 ); fieldConstraints.insets = new Insets( 20, 4, 4, 20 ); gb.setConstraints( idField, fieldConstraints ); loginPane.add( idField ); JLabel passLabel = new JLabel( "Password" ); labelConstraints.insets = new Insets( 4, 20, 4, 4 ); gb.setConstraints( passLabel, labelConstraints ); loginPane.add( passLabel ); passField = new JPasswordField( 15 ); fieldConstraints.insets = new Insets( 4, 4, 4, 20 ); gb.setConstraints( passField, fieldConstraints ); loginPane.add( passField ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); Collection databases = settings.getDatabases(); Vector dbNames = new Vector(); Iterator iter = databases.iterator(); while ( iter.hasNext() ) { PVDatabase db = (PVDatabase) iter.next(); dbNames.add( db.getName() ); } Object[] dbs = dbNames.toArray(); JLabel dbLabel = new JLabel( "Database" ); gb.setConstraints( dbLabel, labelConstraints ); loginPane.add( dbLabel ); dbField = new JComboBox( dbs ); gb.setConstraints( dbField, fieldConstraints ); loginPane.add( dbField ); getContentPane().add( loginPane, BorderLayout.NORTH ); JButton newDbBtn = new JButton( "New database..." ); newDbBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_NEWDB; setVisible( false ); } }); JButton okBtn = new JButton( "OK" ); final LoginDlg dlg = this; okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_APPROVE; setVisible( false ); } } ); JButton cancelBtn = new JButton( "Cancel" ); cancelBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_CANCEL; setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add( newDbBtn ); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(cancelBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( okBtn ); pack(); // setResizable( false ); // Center the dialog on screen int w = getSize().width; int h = getSize().height; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screenSize.width-w)/2; int y = (screenSize.height-h)/2; setLocation( x, y ); }
|
protected void createUI() { GridBagConstraints labelConstraints = new GridBagConstraints(); labelConstraints.insets = new Insets( 2, 20, 2, 2 ); labelConstraints.anchor = GridBagConstraints.EAST; labelConstraints.gridwidth = GridBagConstraints.RELATIVE; //next-to-last labelConstraints.fill = GridBagConstraints.NONE; //reset to default labelConstraints.weightx = 0.0; //reset to default GridBagConstraints fieldConstraints = new GridBagConstraints(); fieldConstraints.insets = new Insets( 2, 2, 2, 20 ); fieldConstraints.anchor = GridBagConstraints.WEST; fieldConstraints.gridwidth = GridBagConstraints.REMAINDER; //end row fieldConstraints.weightx = 1.0; JPanel loginPane = new JPanel(); GridBagLayout gb = new GridBagLayout(); loginPane.setLayout( gb ); JLabel idLabel = new JLabel( "Username" ); labelConstraints.insets = new Insets( 20, 20, 4, 4 ); gb.setConstraints( idLabel, labelConstraints ); loginPane.add( idLabel ); idField = new JTextField( 15 ); fieldConstraints.insets = new Insets( 20, 4, 4, 20 ); gb.setConstraints( idField, fieldConstraints ); loginPane.add( idField ); JLabel passLabel = new JLabel( "Password" ); labelConstraints.insets = new Insets( 4, 20, 4, 4 ); gb.setConstraints( passLabel, labelConstraints ); loginPane.add( passLabel ); passField = new JPasswordField( 15 ); fieldConstraints.insets = new Insets( 4, 4, 4, 20 ); gb.setConstraints( passField, fieldConstraints ); loginPane.add( passField ); PhotovaultSettings settings = PhotovaultSettings.getSettings(); Collection databases = settings.getDatabases(); Vector dbNames = new Vector(); Iterator iter = databases.iterator(); while ( iter.hasNext() ) { PVDatabase db = (PVDatabase) iter.next(); dbNames.add( db.getName() ); } Object[] dbs = dbNames.toArray(); JLabel dbLabel = new JLabel( "Database" ); gb.setConstraints( dbLabel, labelConstraints ); loginPane.add( dbLabel ); dbField = new JComboBox( dbs ); gb.setConstraints( dbField, fieldConstraints ); loginPane.add( dbField ); getContentPane().add( loginPane, BorderLayout.NORTH ); JButton newDbBtn = new JButton( "New database..." ); newDbBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_NEWDB; setVisible( false ); } }); JButton okBtn = new JButton( "OK" ); okBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_APPROVE; setVisible( false ); } } ); JButton cancelBtn = new JButton( "Cancel" ); cancelBtn.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { returnReason = RETURN_REASON_CANCEL; setVisible( false ); } } ); JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); buttonPane.add(Box.createHorizontalGlue()); buttonPane.add( newDbBtn ); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(okBtn); buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); buttonPane.add(cancelBtn); getContentPane().add( buttonPane, BorderLayout.SOUTH ); getRootPane().setDefaultButton( okBtn ); pack(); // setResizable( false ); // Center the dialog on screen int w = getSize().width; int h = getSize().height; Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int x = (screenSize.width-w)/2; int y = (screenSize.height-h)/2; setLocation( x, y ); }
| 1,111,556
|
public void doTag(XMLOutput output) throws Exception { task.init(); if ( "echo".equals( task.getTaskName() ) ) { Echo echoTask = (Echo) task; echoTask.addText( getBodyText() ); echoTask.perform(); echoTask.setMessage( "" ); } else { // run the body first to configure the task via nested getBody().run(context, output); task.perform(); } }
|
public void doTag(XMLOutput output) throws Exception { task.init(); if ( "echo".equals( task.getTaskName() ) ) { Echo echoTask = (Echo) task; echoTask.addText( getBodyText() ); echoTask.perform(); echoTask.setMessage( "" ); } else { // run the body first to configure the task via nested getBody().run(context, output); task.perform(); } }
| 1,111,557
|
public Task getTask() { return task; }
|
public Task getTask() throws Exception { if ( task == null ) { task = (Task) taskType.newInstance(); task.setProject(project); task.setTaskName(taskName); task.init(); setDynaBean( new ConvertingWrapDynaBean(task) ); } return task; }
| 1,111,558
|
public Object getTaskObject() { return task; }
|
public Object getTaskObject() { return task; }
| 1,111,559
|
public long getMorganDistance(){ return morganDistance; }
|
public double getMorganDistance(){ return morganDistance; }
| 1,111,560
|
protected Object createWidget(Class theClass, Widget parent, int style) throws Exception { if (theClass == null) { throw new JellyException( "No Class available to create the new widget"); } if (parent == null) { // lets try call a constructor with a single style Class[] types = { int.class }; Constructor constructor = theClass.getConstructor(types); if (constructor != null) { Object[] arguments = { new Integer(style)}; return constructor.newInstance(arguments); } } else { // lets try to find the constructor with 2 arguments with the 2nd argument being an int Constructor[] constructors = theClass.getConstructors(); if (constructors != null) { for (int i = 0, size = constructors.length; i < size; i++ ) { Constructor constructor = constructors[i]; Class[] types = constructor.getParameterTypes(); if (types.length == 2 && types[1].isAssignableFrom(int.class)) { Object[] arguments = { parent, new Integer(style)}; return constructor.newInstance(arguments); } } } } return theClass.newInstance(); }
|
protected Object createWidget(Class theClass, Widget parent, int style) throws Exception { if (theClass == null) { throw new JellyException( "No Class available to create the new widget"); } if (parent == null) { // lets try call a constructor with a single style Class[] types = { int.class }; Constructor constructor = theClass.getConstructor(types); if (constructor != null) { Object[] arguments = { new Integer(style)}; return constructor.newInstance(arguments); } } else { // lets try to find the constructor with 2 arguments with the 2nd argument being an int Constructor[] constructors = theClass.getConstructors(); if (constructors != null) { for (int i = 0, size = constructors.length; i < size; i++ ) { Constructor constructor = constructors[i]; Class[] types = constructor.getParameterTypes(); if (types.length == 2 && types[1].isAssignableFrom(int.class)) { Object[] arguments = { parent, new Integer(style)}; return constructor.newInstance(arguments); } } } } return theClass.newInstance(); }
| 1,111,561
|
public void drop(DropTargetDropEvent dtde) { if (tpTarget != null) { tpTarget.getDropTarget().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: this is bad ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
|
public void drop(DropTargetDropEvent dtde) { if (tpTarget != null) { tpTarget.getDropTarget().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); // XXX: this is bad ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
| 1,111,562
|
public void drop(DropTargetDropEvent dtde) { if (tpTarget != null) { tpTarget.getDropTarget().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: this is bad ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
|
public void drop(DropTargetDropEvent dtde) { if (tpTarget != null) { tpTarget.getDropTarget().drop(dtde); return; } Transferable t = dtde.getTransferable(); PlayPen c = (PlayPen) dtde.getDropTargetContext().getComponent(); DataFlavor importFlavor = bestImportFlavor(c, t.getTransferDataFlavors()); if (importFlavor == null) { dtde.rejectDrop(); } else { try { dtde.acceptDrop(DnDConstants.ACTION_COPY); DBTree dbtree = ArchitectFrame.getMainInstance().dbTree; // XXX: this is bad ArrayList paths = (ArrayList) t.getTransferData(importFlavor); Iterator pathIt = paths.iterator(); Point dropLoc = c.unzoomPoint(new Point(dtde.getLocation())); while (pathIt.hasNext()) { Object someData = dbtree.getNodeForDnDPath((int[]) pathIt.next()); if (someData instanceof SQLTable) { TablePane tp = c.importTableCopy((SQLTable) someData, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } else if (someData instanceof SQLSchema) { SQLSchema sourceSchema = (SQLSchema) someData; c.addSchema(sourceSchema, dropLoc); } else if (someData instanceof SQLCatalog) { SQLCatalog sourceCatalog = (SQLCatalog) someData; Iterator cit = sourceCatalog.getChildren().iterator(); if (sourceCatalog.isSchemaContainer()) { while (cit.hasNext()) { SQLSchema sourceSchema = (SQLSchema) cit.next(); c.addSchema(sourceSchema, dropLoc); } } else { while (cit.hasNext()) { SQLTable sourceTable = (SQLTable) cit.next(); TablePane tp = c.importTableCopy(sourceTable, dropLoc); dropLoc.x += tp.getPreferredSize().width + 5; } } } else if (someData instanceof SQLColumn) { SQLColumn column = (SQLColumn) someData; JLabel colName = new JLabel(column.getColumnName()); colName.setSize(colName.getPreferredSize()); c.add(colName, dropLoc); logger.debug("Added "+column.getColumnName()+" to playpen (temporary, only for testing)"); colName.revalidate(); } else { logger.error("Unknown object dropped in PlayPen: "+someData); dtde.rejectDrop(); } } dtde.dropComplete(true); } catch (UnsupportedFlavorException ufe) { logger.error(ufe); dtde.rejectDrop(); } catch (IOException ioe) { logger.error(ioe); dtde.rejectDrop(); } catch (InvalidDnDOperationException ex) { logger.error(ex); dtde.rejectDrop(); } catch (ArchitectException ex) { logger.error(ex); dtde.rejectDrop(); } } }
| 1,111,563
|
public void compile() throws Exception { TaskTag tag = (TaskTag) findAncestorWithClass( TaskTag.class ); if ( tag == null ) { throw new JellyException( "You should only use Ant DataType tags within an Ant Task" ); } Task task = tag.getTask(); Class taskClass = task.getClass(); String methodName = "create" + name.substring(0,1).toUpperCase() + name.substring(1); Method method = taskClass.getMethod( methodName, emptyParameterTypes ); if ( method == null ) { throw new JellyException( "Cannot create Task property: " + name + " of Ant task: " + task + " as no method called: " + methodName + " could be found" ); } Object propertyBean = method.invoke( task, emptyParameters ); if ( propertyBean == null ) { throw new JellyException( "No property: " + name + " of task: " + task + " was returned." ); } setDynaBean( new WrapDynaBean(propertyBean) ); }
|
public void compile() throws Exception { TaskTag tag = (TaskTag) findAncestorWithClass( TaskTag.class ); if ( tag == null ) { throw new JellyException( "You should only use Ant DataType tags within an Ant Task" ); } Task task = tag.getTask(); Class taskClass = task.getClass(); String methodName = "create" + name.substring(0,1).toUpperCase() + name.substring(1); Method method = taskClass.getMethod( methodName, emptyParameterTypes ); if ( method == null ) { throw new JellyException( "Cannot create Task property: " + name + " of Ant task: " + task + " as no method called: " + methodName + " could be found" ); } Object propertyBean = method.invoke( task, emptyParameters ); if ( propertyBean == null ) { throw new JellyException( "No property: " + name + " of task: " + task + " was returned." ); } setDynaBean( new ConvertingWrapDynaBean(propertyBean) ); }
| 1,111,564
|
private void buildCCSet(PedFile pf, Vector affectedStatus, TreeSet snpsToBeTested){ ArrayList results = new ArrayList(); int numMarkers = Chromosome.getUnfilteredSize(); Vector indList = pf.getUnrelatedIndividuals(); int numInds = indList.size(); if(affectedStatus == null || affectedStatus.size() != indList.size()) { affectedStatus = new Vector(indList.size()); for(int i=0;i<indList.size();i++) { Individual tempInd = ((Individual)indList.get(i)); affectedStatus.add(new Integer(tempInd.getAffectedStatus())); } } boolean[] useable = new boolean[indList.size()]; Arrays.fill(useable, false); //this loop determines who is eligible to be used for the case/control association test for(int i=0;i<useable.length;i++) { Individual tempInd = ((Individual)indList.get(i)); Family tempFam = pf.getFamily(tempInd.getFamilyID()); //need to check to make sure we don't include both parents and kids of trios //so, we only set useable[i] to true if Individual at index i is not the child of a trio in the indList if (!(tempFam.containsMember(tempInd.getMomID()) && tempFam.containsMember(tempInd.getDadID()))){ useable[i] = true; } else{ try{ if (!(indList.contains(tempFam.getMember(tempInd.getMomID())) || indList.contains(tempFam.getMember(tempInd.getDadID())))){ useable[i] = true; } }catch (PedFileException pfe){ } } } for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ byte allele1 = 0, allele2 = 0; int[][] counts = new int[2][2]; Individual currentInd; for (int j = 0; j < numInds; j++){ if(useable[j]) { currentInd = (Individual)indList.get(j); int cc = ((Integer)affectedStatus.get(j)).intValue(); if (cc == 0) continue; if (cc == 2) cc = 0; byte a1 = currentInd.getAllele(i,0); byte a2 = currentInd.getAllele(i,1); if (a1 >= 5 && a2 >= 5){ counts[cc][0]++; counts[cc][1]++; if (allele1 == 0){ allele1 = (byte)(a1 - 4); allele2 = (byte)(a2 - 4); } }else{ //seed the alleles as soon as they're found if (allele1 == 0){ allele1 = a1; if (a1 != a2){ allele2 = a2; } }else if (allele2 == 0){ if (a1 != allele1){ allele2 = a1; }else if (a2 != allele1){ allele2 = a2; } } if (a1 != 0){ if (a1 == allele1){ counts[cc][0] ++; }else{ counts[cc][1] ++; } } if (currentInd.getGender() == 2 || !Chromosome.getDataChrom().equals("chrx")){ if (a2 != 0){ if (a2 == allele1){ counts[cc][0]++; }else{ counts[cc][1]++; } } } } } } int[] g1 = {allele1}; int[] g2 = {allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setCaseCount(counts[0][0]); thisSNP1.setControlCount(counts[1][0]); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setCaseCount(counts[0][1]); thisSNP2.setControlCount(counts[1][1]); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getDisplayName(), currentMarker)); } } this.results = new Vector(results); }
|
private void buildCCSet(PedFile pf, Vector affectedStatus, TreeSet snpsToBeTested){ ArrayList results = new ArrayList(); int numMarkers = Chromosome.getUnfilteredSize(); Vector indList = pf.getUnrelatedIndividuals(); int numInds = indList.size(); if(affectedStatus == null || affectedStatus.size() != indList.size()) { affectedStatus = new Vector(indList.size()); for(int i=0;i<indList.size();i++) { Individual tempInd = ((Individual)indList.get(i)); affectedStatus.add(new Integer(tempInd.getAffectedStatus())); } } boolean[] useable = new boolean[indList.size()]; Arrays.fill(useable, false); //this loop determines who is eligible to be used for the case/control association test for(int i=0;i<useable.length;i++) { Individual tempInd = ((Individual)indList.get(i)); Family tempFam = pf.getFamily(tempInd.getFamilyID()); //need to check to make sure we don't include both parents and kids of trios //so, we only set useable[i] to true if Individual at index i is not the child of a trio in the indList if (!(tempFam.containsMember(tempInd.getMomID()) && tempFam.containsMember(tempInd.getDadID()))){ useable[i] = true; } else{ try{ if (!(indList.contains(tempFam.getMember(tempInd.getMomID())) || indList.contains(tempFam.getMember(tempInd.getDadID())))){ useable[i] = true; } }catch (PedFileException pfe){ } } } for (int i = 0; i < numMarkers; i++){ SNP currentMarker = Chromosome.getUnfilteredMarker(i); if (snpsToBeTested.contains(currentMarker)){ byte allele1 = 0, allele2 = 0; int[][] counts = new int[2][2]; Individual currentInd; for (int j = 0; j < numInds; j++){ if(useable[j]) { currentInd = (Individual)indList.get(j); int cc = ((Integer)affectedStatus.get(j)).intValue(); if (cc == 0) continue; if (cc == 2) cc = 0; byte a1 = currentInd.getAllele(i,0); byte a2 = currentInd.getAllele(i,1); if (a1 >= 5 && a2 >= 5){ counts[cc][0]++; counts[cc][1]++; if (allele1 == 0){ allele1 = (byte)(a1 - 4); allele2 = (byte)(a2 - 4); } }else{ //seed the alleles as soon as they're found if (allele1 == 0){ allele1 = a1; if (a1 != a2){ allele2 = a2; } }else if (allele2 == 0){ if (a1 != allele1){ allele2 = a1; }else if (a2 != allele1){ allele2 = a2; } } if (a1 != 0){ if (a1 == allele1){ counts[cc][0] ++; }else{ counts[cc][1] ++; } } if (currentInd.getGender() == 2 || !Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ if (a2 != 0){ if (a2 == allele1){ counts[cc][0]++; }else{ counts[cc][1]++; } } } } } } int[] g1 = {allele1}; int[] g2 = {allele2}; int[] m = {i}; Haplotype thisSNP1 = new Haplotype(g1, 0, m, null); thisSNP1.setCaseCount(counts[0][0]); thisSNP1.setControlCount(counts[1][0]); Haplotype thisSNP2 = new Haplotype(g2, 0, m, null); thisSNP2.setCaseCount(counts[0][1]); thisSNP2.setControlCount(counts[1][1]); Haplotype[] daBlock = {thisSNP1, thisSNP2}; results.add(new MarkerAssociationResult(daBlock, currentMarker.getDisplayName(), currentMarker)); } } this.results = new Vector(results); }
| 1,111,565
|
public void doTag(XMLOutput xmlOutput) throws Exception { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( "<notFoundHandler> tag must be enclosed inside a <httpContext> tag" ); } NotFoundHandler notFoundHandler = new NotFoundHandler(); httpContext.addHandler(notFoundHandler); invokeBody(xmlOutput); }
|
public void doTag(XMLOutput xmlOutput) throws JellyTagException { HttpContextTag httpContext = (HttpContextTag) findAncestorWithClass( HttpContextTag.class); if ( httpContext == null ) { throw new JellyTagException( "<notFoundHandler> tag must be enclosed inside a <httpContext> tag" ); } NotFoundHandler notFoundHandler = new NotFoundHandler(); httpContext.addHandler(notFoundHandler); invokeBody(xmlOutput); }
| 1,111,566
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,567
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; if (logger.isDebugEnabled()) logger.debug("identifiers must start with letter; prepending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,568
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; if (logger.isDebugEnabled()) logger.debug("identifier was reserved word, prepending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,569
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,570
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() <= 63) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,571
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,572
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; if (logger.isDebugEnabled()) logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,573
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName if (logger.isDebugEnabled()) logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,574
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,575
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
|
public String toIdentifier(String logicalName, String physicalName) { // replace spaces with underscores if (logicalName == null) return null; logger.debug("getting physical name for: " + logicalName); String ident = logicalName.replace(' ','_').toUpperCase(); logger.debug("after replace of spaces: " + ident); // make sure first character is alpha Pattern p = Pattern.compile("^[^a-zA-Z]+"); Matcher m = p.matcher(ident); if (m.find()) { // just add something alpha to the front for now ident = "X" + ident; logger.debug("identifiers must start with letter, appending X: " + ident); } // see if it's a reserved word, and add something alpha to front if it is... if (isReservedWord(ident)) { ident = "X" + ident; logger.debug("identifier was reserved word, appending X: " + ident); } // replace anything that is not a letter, character, or underscore with an underscore... String tempString = ident; Pattern p2 = Pattern.compile("[^a-xA-Z0-9_$]"); Matcher m2 = p2.matcher(ident); while (m2.find()) { tempString = tempString.replace(m2.group(),"_"); } // first time through if (physicalName == null) { // length is ok if (ident.length() < 129) { return ident; } else { // length is too big logger.debug("truncating identifier: " + ident); String base = ident.substring(0,125); int tiebreaker = ((ident.hashCode() % 1000) + 1000) % 1000; logger.debug("new identifier: " + base + tiebreaker); return (base + tiebreaker); } } else { // back for more, which means that we probably // had a namespace conflict. Hack the ident down // to size if it's too big, and then generate // a hash tiebreaker using the ident and the // passed value physicalName logger.debug("physical identifier is not unique, regenerating: " + physicalName); String base = ident; if (ident.length() > 125) { base = ident.substring(0,125); } int tiebreaker = (((ident + physicalName).hashCode() % 1000) + 1000) % 1000; if (logger.isDebugEnabled()) logger.debug("regenerated identifier is: " + (base + tiebreaker)); return (base + tiebreaker); } }
| 1,111,576
|
public void writeHeader() { out.println("-- Created by SQLPower DB2 DDL Generator "+GENERATOR_VERSION+" --"); }
|
public void writeHeader() { println("-- Created by SQLPower DB2 DDL Generator "+GENERATOR_VERSION+" --"); }
| 1,111,577
|
public void actionPerformed(ActionEvent e) { // ArchitectPanelBuilder cannot handle this because of the // wizard-style buttons (right-justified FlowLayout). final JDialog d = new JDialog(frame,title ); JPanel plr = new JPanel(new BorderLayout(12,12)); plr.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final DBCSPanel dbcsPanel = new DBCSPanel(); dbcsPanel.setDbcs(new ArchitectDataSource()); plr.add(dbcsPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JButton okButton = new JButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.applyChanges(); ArchitectDataSource dbcs = dbcsPanel.getDbcs(); if ( comboBox != null ) { comboBox.addItem(dbcs); comboBox.setSelectedItem(dbcs); } frame.getUserSettings().getPlDotIni().addDataSource(dbcs); d.setVisible(false); } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); d.setVisible(false); } }; JButton cancelButton = new JButton(cancelAction); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); buttonPanel.add(cancelButton); plr.add(buttonPanel, BorderLayout.SOUTH); d.getRootPane().setDefaultButton(okButton); d.setContentPane(plr); d.pack(); d.setLocationRelativeTo(frame); d.setVisible(true); }
|
public void actionPerformed(ActionEvent e) { // ArchitectPanelBuilder cannot handle this because of the // wizard-style buttons (right-justified FlowLayout). final JDialog d = new JDialog(frame,title ); JPanel plr = new JPanel(new BorderLayout(12,12)); plr.setBorder(BorderFactory.createEmptyBorder(12,12,12,12)); final DBCSPanel dbcsPanel = new DBCSPanel(); dbcsPanel.setDbcs(new ArchitectDataSource()); plr.add(dbcsPanel, BorderLayout.CENTER); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); JDefaultButton okButton = new JDefaultButton(ArchitectPanelBuilder.OK_BUTTON_LABEL); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { dbcsPanel.applyChanges(); ArchitectDataSource dbcs = dbcsPanel.getDbcs(); if ( comboBox != null ) { comboBox.addItem(dbcs); comboBox.setSelectedItem(dbcs); } frame.getUserSettings().getPlDotIni().addDataSource(dbcs); d.setVisible(false); } }); buttonPanel.add(okButton); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); d.setVisible(false); } }; JButton cancelButton = new JButton(cancelAction); ArchitectPanelBuilder.makeJDialogCancellable(d, cancelAction); buttonPanel.add(cancelButton); plr.add(buttonPanel, BorderLayout.SOUTH); d.getRootPane().setDefaultButton(okButton); d.setContentPane(plr); d.pack(); d.setLocationRelativeTo(frame); d.setVisible(true); }
| 1,111,578
|
protected Project getProject() { ProjectTag tag = (ProjectTag) findAncestorWithClass(ProjectTag.class); if ( tag != null) { return tag.getProject(); } return (Project) context.getVariable( "org.apache.commons.jelly.werkz.Project" ); }
|
protected Project getProject() { ProjectTag tag = (ProjectTag) findAncestorWithClass(ProjectTag.class); if ( tag != null) { return tag.getProject(); } return (Project) context.findVariable( "org.apache.commons.jelly.werkz.Project" ); }
| 1,111,579
|
public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } }
|
public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(dbcs); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } }
| 1,111,580
|
public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } }
|
public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,false); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } }
| 1,111,581
|
public void run(JellyContext context, XMLOutput output) throws Exception { Tag tag = getTag(); if ( tag == null ) { return; } tag.setContext(context); // initialize all the properties of the tag before its used // if there is a problem abort this tag for (int i = 0, size = expressions.length; i < size; i++) { Expression expression = expressions[i]; Method method = methods[i]; Class type = types[i]; // some types are Expression objects so let the tag // evaluate them Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluate(context); } // convert value to correct type if (value != null) { value = convertType(value, type); } Object[] arguments = { value }; try { method.invoke(tag, arguments); } catch (Exception e) { String valueTypeName = (value != null ) ? value.getClass().getName() : "null"; log.warn( "Cannot call method: " + method.getName() + " as I cannot convert: " + value + " of type: " + valueTypeName + " into type: " + type.getName() ); throw createJellyException( "Cannot call method: " + method.getName() + " on tag of type: " + tag.getClass().getName() + " with value: " + value + " of type: " + valueTypeName + ". Exception: " + e, e ); } } try { tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } finally { if ( ! context.isCacheTags() ) { clearTag(); } } }
|
public void run(JellyContext context, XMLOutput output) throws Exception { Tag tag = getTag(); if ( tag == null ) { return; } tag.setContext(context); // initialize all the properties of the tag before its used // if there is a problem abort this tag for (int i = 0, size = expressions.length; i < size; i++) { Expression expression = expressions[i]; Method method = methods[i]; Class type = types[i]; // some types are Expression objects so let the tag // evaluate them Object value = null; if (type.isAssignableFrom(Expression.class) && !type.isAssignableFrom(Object.class)) { value = expression; } else { value = expression.evaluate(context); } // convert value to correct type if (value != null) { value = convertType(value, type); } Object[] arguments = { value }; try { method.invoke(tag, arguments); } catch (Exception e) { String valueTypeName = (value != null ) ? value.getClass().getName() : "null"; log.warn( "Cannot call method: " + method.getName() + " as I cannot convert: " + value + " of type: " + valueTypeName + " into type: " + type.getName() ); throw createJellyException( "Cannot call method: " + method.getName() + " on tag of type: " + tag.getClass().getName() + " with value: " + value + " of type: " + valueTypeName + ". Exception: " + e, e ); } } try { tag.doTag(output); } catch (JellyException e) { handleException(e); } catch (Exception e) { handleException(e); } finally { if ( ! context.isCacheTags() ) { clearTag(); } } }
| 1,111,582
|
void prepareMarkerInput(File infile, String[][] hapmapGoodies) throws IOException, HaploViewException{ //this method is called to gather data about the markers used. //It is assumed that the input file is two columns, the first being //the name and the second the absolute position. the maxdist is //used to determine beyond what distance comparisons will not be //made. if the infile param is null, loads up "dummy info" for //situation where no info file exists //An optional third column is supported which is designed to hold //association study data. If there is a third column there will be //a visual indicator in the D' display that there is additional data //and the detailed data can be viewed with a mouse press. Vector names = new Vector(); Vector positions = new Vector(); Vector extras = new Vector(); dupsToBeFlagged = false; try{ if (infile != null){ if (infile.length() < 1){ throw new HaploViewException("Info file is empty or does not exist: " + infile.getName()); } String currentLine; long prevloc = -1000000000; //read the input file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; while ((currentLine = in.readLine()) != null){ StringTokenizer st = new StringTokenizer(currentLine); if (st.countTokens() > 1){ lineCount++; }else if (st.countTokens() == 1){ //complain if only one field found throw new HaploViewException("Info file format error on line "+lineCount+ ":\n Info file must be of format: <markername> <markerposition>"); }else{ //skip blank lines continue; } String name = st.nextToken(); String l = st.nextToken(); String extra = null; if (st.hasMoreTokens()) extra = st.nextToken(); long loc; try{ loc = Long.parseLong(l); }catch (NumberFormatException nfe){ throw new HaploViewException("Info file format error on line "+lineCount+ ":\n\"" + l + "\" should be of type long." + "\n Info file must be of format: <markername> <markerposition>"); } //basically if anyone is crazy enough to load a dataset, then go back and load //an out-of-order info file we tell them to bugger off and start over. if (loc < prevloc && Chromosome.markers != null){ throw new HaploViewException("Info file out of order with preloaded dataset:\n"+ name + "\nPlease reload data file and info file together."); } prevloc = loc; names.add(name); positions.add(l); extras.add(extra); } if (lineCount > Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too many\nmarkers in info file compared to data file.")); } if (lineCount < Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too few\nmarkers in info file compared to data file.")); } infoKnown=true; } if (hapmapGoodies != null){ //we know some stuff from the hapmap so we'll add it here for (int x=0; x < hapmapGoodies.length; x++){ names.add(hapmapGoodies[x][0]); positions.add(hapmapGoodies[x][1]); extras.add(null); } infoKnown = true; } else if (infile != null){ //we only sort if we read the info from an info file. if //it is from a hapmap file, then the markers were already sorted //when they were read in (in class Pedfile). int numLines = names.size(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines]; boolean needSort = false; //this loop stores the positions of each marker in an array (pos[]) in the order they appear in the file. //it also creates a hashtable with the positions as keys and their index in the pos[] array as the value for (int k = 0; k < (numLines); k++){ pos[k] = new Long((String)(positions.get(k))).longValue(); sortHelp.put(new Long(pos[k]),new Integer(k)); } //loop through and check if any markers are out of order for (int k = 1; k < (numLines); k++){ if(pos[k] < pos[k-1]) { needSort = true; break; } } //if any were out of order, then we need to put them in order if(needSort) { //sort the positions Arrays.sort(pos); Vector newNames = new Vector(); Vector newExtras = new Vector(); Vector newPositions = new Vector(); int[] realPos = new int[numLines]; //reorder the vectors names and extras so that they have the same order as the sorted markers for (int i = 0; i < pos.length; i++){ realPos[i] = ((Integer)(sortHelp.get(new Long(pos[i])))).intValue(); newNames.add(names.get(realPos[i])); newPositions.add(positions.get(realPos[i])); newExtras.add(extras.get(realPos[i])); } names = newNames; extras = newExtras; positions = newPositions; byte[] tempGenotype = new byte[pos.length]; //now we reorder all the individuals genotypes according to the sorted marker order for(int j=0;j<chromosomes.size();j++){ Chromosome tempChrom = (Chromosome)chromosomes.elementAt(j); for(int i =0;i<pos.length;i++){ tempGenotype[i] = tempChrom.getUnfilteredGenotype(realPos[i]); } for(int i=0;i<pos.length;i++) { tempChrom.setGenotype(tempGenotype[i],i); } } } } }catch (HaploViewException e){ throw(e); }finally{ double numChroms = chromosomes.size(); Vector markerInfo = new Vector(); double[] numBadGenotypes = new double[Chromosome.getUnfilteredSize()]; percentBadGenotypes = new double[Chromosome.getUnfilteredSize()]; Vector results = null; if (pedFile != null){ results = pedFile.getResults(); } long prevPosition = Long.MIN_VALUE; SNP prevMarker = null; for (int i = 0; i < Chromosome.getUnfilteredSize(); i++){ MarkerResult mr = null; if (results != null){ mr = (MarkerResult)results.elementAt(i); } //to compute minor/major alleles, browse chrom list and count instances of each allele byte a1 = 0; byte a2 = 0; double numa1 = 0; double numa2 = 0; for (int j = 0; j < chromosomes.size(); j++){ //if there is a data point for this marker on this chromosome byte thisAllele = ((Chromosome)chromosomes.elementAt(j)).getUnfilteredGenotype(i); if (!(thisAllele == 0)){ if (thisAllele >= 5){ numa1+=0.5; numa2+=0.5; if (thisAllele < 9){ if (a1==0){ a1 = (byte)(thisAllele-4); }else if (a2 == 0){ if (!(thisAllele-4 == a1)){ a2 = (byte)(thisAllele-4); } } } }else if (a1 == 0){ a1 = thisAllele; numa1++; }else if (thisAllele == a1){ numa1++; }else{ numa2++; a2 = thisAllele; } } else { numBadGenotypes[i]++; } } if (numa2 > numa1){ byte temp = a1; a1 = a2; a2 = temp; } double maf; if (mr != null){ maf = Math.rint(mr.getMAF()*100.0)/100.0; }else{ maf = Math.rint(100.0*(numa1/(numa1+numa2)))/100.0; } if (infoKnown){ long pos = Long.parseLong((String)positions.elementAt(i)); SNP thisMarker = (new SNP((String)names.elementAt(i), pos, maf, a1, a2, (String)extras.elementAt(i))); markerInfo.add(thisMarker); if (mr != null){ double genoPC = mr.getGenoPercent(); //check to make sure adjacent SNPs do not have identical positions if (prevPosition != Long.MIN_VALUE){ //only do this for markers 2..N, since we're comparing to the previous location if (pos == prevPosition){ dupsToBeFlagged = true; if (genoPC >= mr.getGenoPercent()){ //use this one because it has more genotypes thisMarker.setDup(1); prevMarker.setDup(2); }else{ //use the other one because it has more genotypes thisMarker.setDup(2); prevMarker.setDup(1); } } } prevPosition = pos; prevMarker = thisMarker; } }else{ markerInfo.add(new SNP("Marker " + String.valueOf(i+1), (i*4000), maf,a1,a2)); } percentBadGenotypes[i] = numBadGenotypes[i]/numChroms; } Chromosome.markers = markerInfo.toArray(); } }
|
void prepareMarkerInput(File infile, String[][] hapmapGoodies) throws IOException, HaploViewException{ //this method is called to gather data about the markers used. //It is assumed that the input file is two columns, the first being //the name and the second the absolute position. the maxdist is //used to determine beyond what distance comparisons will not be //made. if the infile param is null, loads up "dummy info" for //situation where no info file exists //An optional third column is supported which is designed to hold //association study data. If there is a third column there will be //a visual indicator in the D' display that there is additional data //and the detailed data can be viewed with a mouse press. Vector names = new Vector(); Vector positions = new Vector(); Vector extras = new Vector(); dupsToBeFlagged = false; try{ if (infile != null){ if (infile.length() < 1){ throw new HaploViewException("Info file is empty or does not exist: " + infile.getName()); } String currentLine; long prevloc = -1000000000; //read the input file: BufferedReader in = new BufferedReader(new FileReader(infile)); int lineCount = 0; while ((currentLine = in.readLine()) != null){ StringTokenizer st = new StringTokenizer(currentLine); if (st.countTokens() > 1){ lineCount++; }else if (st.countTokens() == 1){ //complain if only one field found throw new HaploViewException("Info file format error on line "+lineCount+ ":\n Info file must be of format: <markername> <markerposition>"); }else{ //skip blank lines continue; } String name = st.nextToken(); String l = st.nextToken(); String extra = null; if (st.hasMoreTokens()) extra = st.nextToken(); long loc; try{ loc = Long.parseLong(l); }catch (NumberFormatException nfe){ throw new HaploViewException("Info file format error on line "+lineCount+ ":\n\"" + l + "\" should be of type long." + "\n Info file must be of format: <markername> <markerposition>"); } //basically if anyone is crazy enough to load a dataset, then go back and load //an out-of-order info file we tell them to bugger off and start over. if (loc < prevloc && Chromosome.markers != null){ throw new HaploViewException("Info file out of order with preloaded dataset:\n"+ name + "\nPlease reload data file and info file together."); } prevloc = loc; names.add(name); positions.add(l); extras.add(extra); } if (lineCount > Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too many\nmarkers in info file compared to data file.")); } if (lineCount < Chromosome.getUnfilteredSize()){ throw(new HaploViewException("Info file error:\nMarker number mismatch: too few\nmarkers in info file compared to data file.")); } infoKnown=true; } if (hapmapGoodies != null){ //we know some stuff from the hapmap so we'll add it here for (int x=0; x < hapmapGoodies.length; x++){ names.add(hapmapGoodies[x][0]); positions.add(hapmapGoodies[x][1]); extras.add(null); } infoKnown = true; } else if (infile != null){ //we only sort if we read the info from an info file. if //it is from a hapmap file, then the markers were already sorted //when they were read in (in class Pedfile). int numLines = names.size(); Hashtable sortHelp = new Hashtable(numLines-1,1.0f); long[] pos = new long[numLines]; boolean needSort = false; //this loop stores the positions of each marker in an array (pos[]) in the order they appear in the file. //it also creates a hashtable with the positions as keys and their index in the pos[] array as the value for (int k = 0; k < (numLines); k++){ pos[k] = new Long((String)(positions.get(k))).longValue(); sortHelp.put(new Long(pos[k]),new Integer(k)); } //loop through and check if any markers are out of order for (int k = 1; k < (numLines); k++){ if(pos[k] < pos[k-1]) { needSort = true; break; } } //if any were out of order, then we need to put them in order if(needSort) { //sort the positions Arrays.sort(pos); Vector newNames = new Vector(); Vector newExtras = new Vector(); Vector newPositions = new Vector(); int[] realPos = new int[numLines]; //reorder the vectors names and extras so that they have the same order as the sorted markers for (int i = 0; i < pos.length; i++){ realPos[i] = ((Integer)(sortHelp.get(new Long(pos[i])))).intValue(); newNames.add(names.get(realPos[i])); newPositions.add(positions.get(realPos[i])); newExtras.add(extras.get(realPos[i])); } names = newNames; extras = newExtras; positions = newPositions; byte[] tempGenotype = new byte[pos.length]; //now we reorder all the individuals genotypes according to the sorted marker order for(int j=0;j<chromosomes.size();j++){ Chromosome tempChrom = (Chromosome)chromosomes.elementAt(j); for(int i =0;i<pos.length;i++){ tempGenotype[i] = tempChrom.getUnfilteredGenotype(realPos[i]); } for(int i=0;i<pos.length;i++) { tempChrom.setGenotype(tempGenotype[i],i); } } } } }catch (HaploViewException e){ throw(e); }finally{ double numChroms = chromosomes.size(); Vector markerInfo = new Vector(); double[] numBadGenotypes = new double[Chromosome.getUnfilteredSize()]; percentBadGenotypes = new double[Chromosome.getUnfilteredSize()]; Vector results = null; if (pedFile != null){ results = pedFile.getResults(); } long prevPosition = Long.MIN_VALUE; SNP prevMarker = null; for (int i = 0; i < Chromosome.getUnfilteredSize(); i++){ MarkerResult mr = null; if (results != null){ mr = (MarkerResult)results.elementAt(i); } //to compute minor/major alleles, browse chrom list and count instances of each allele byte a1 = 0; byte a2 = 0; double numa1 = 0; double numa2 = 0; for (int j = 0; j < chromosomes.size(); j++){ //if there is a data point for this marker on this chromosome byte thisAllele = ((Chromosome)chromosomes.elementAt(j)).getUnfilteredGenotype(i); if (!(thisAllele == 0)){ if (thisAllele >= 5){ numa1+=0.5; numa2+=0.5; if (thisAllele < 9){ if (a1==0){ a1 = (byte)(thisAllele-4); }else if (a2 == 0){ if (!(thisAllele-4 == a1)){ a2 = (byte)(thisAllele-4); } } } }else if (a1 == 0){ a1 = thisAllele; numa1++; }else if (thisAllele == a1){ numa1++; }else{ numa2++; a2 = thisAllele; } } else { numBadGenotypes[i]++; } } if (numa2 > numa1){ byte temp = a1; a1 = a2; a2 = temp; } double maf; if (mr != null){ maf = Math.rint(mr.getMAF()*100.0)/100.0; }else{ maf = Math.rint(100.0*(numa2/(numa1+numa2)))/100.0; } if (infoKnown){ long pos = Long.parseLong((String)positions.elementAt(i)); SNP thisMarker = (new SNP((String)names.elementAt(i), pos, maf, a1, a2, (String)extras.elementAt(i))); markerInfo.add(thisMarker); if (mr != null){ double genoPC = mr.getGenoPercent(); //check to make sure adjacent SNPs do not have identical positions if (prevPosition != Long.MIN_VALUE){ //only do this for markers 2..N, since we're comparing to the previous location if (pos == prevPosition){ dupsToBeFlagged = true; if (genoPC >= mr.getGenoPercent()){ //use this one because it has more genotypes thisMarker.setDup(1); prevMarker.setDup(2); }else{ //use the other one because it has more genotypes thisMarker.setDup(2); prevMarker.setDup(1); } } } prevPosition = pos; prevMarker = thisMarker; } }else{ markerInfo.add(new SNP("Marker " + String.valueOf(i+1), (i*4000), maf,a1,a2)); } percentBadGenotypes[i] = numBadGenotypes[i]/numChroms; } Chromosome.markers = markerInfo.toArray(); } }
| 1,111,583
|
public Test_ThumbnailView() { testRefImageDir = new File( "c:\\java\\photovault\\tests\\images\\photovault\\swingui\\TestThumbnailView\\" ); testRefImageDir.mkdirs(); }
|
public Test_ThumbnailView() { testRefImageDir = new File( "/home/harri/projects/photovault/tests/images/photovault/swingui/TestThumbnailView/" ); testRefImageDir.mkdirs(); }
| 1,111,584
|
private boolean compareImgToFile( BufferedImage img, File file ) { if ( file.exists() ) { log.debug( "File exists" ); BufferedImage fImg = null; try { fImg = ImageIO.read( file ); log.debug( "Read image" ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); return false; } boolean eq = equals( img, fImg ); if ( !eq ) { File f = new File( "c:\\temp\\errorFile.png" ); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); try { ImageOutputStream ios = ImageIO.createImageOutputStream(f); writer.setOutput(ios); writer.write( img ); } catch( IOException e ) { fail( e.getMessage() ); } } return eq; } // The image file does not yet exist, so save it Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); try { ImageOutputStream ios = ImageIO.createImageOutputStream(file); writer.setOutput(ios); writer.write(img); } catch( IOException e ) { fail( e.getMessage() ); } return true; }
|
private boolean compareImgToFile( BufferedImage img, File file ) { if ( file.exists() ) { log.debug( "File exists" ); BufferedImage fImg = null; try { fImg = ImageIO.read( file ); log.debug( "Read image" ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); return false; } boolean eq = equals( img, fImg ); if ( !eq ) { File f = new File( "/tmp/errorFile.png" ); Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); try { ImageOutputStream ios = ImageIO.createImageOutputStream(f); writer.setOutput(ios); writer.write( img ); } catch( IOException e ) { fail( e.getMessage() ); } } return eq; } // The image file does not yet exist, so save it Iterator writers = ImageIO.getImageWritersByFormatName("png"); ImageWriter writer = (ImageWriter)writers.next(); try { ImageOutputStream ios = ImageIO.createImageOutputStream(file); writer.setOutput(ios); writer.write(img); } catch( IOException e ) { fail( e.getMessage() ); } return true; }
| 1,111,585
|
protected void setUp() { // Create a frame with the test instance name as the title frame = new JFrame(getName()); pane = (JPanel)frame.getContentPane(); pane.setLayout(new FlowLayout()); pane.setBorder(new EmptyBorder(50, 50, 50, 50)); tester = ComponentTester.getTester(ThumbnailView.class); File f = new File("c:\\java\\photovault\\testfiles\\test1.jpg" ); try { photo = PhotoInfo.addToDB( f ); } catch( PhotoNotFoundException e ) { fail( "error creating photo" ); } photo.setShootingPlace( "TESSTPLACE" ); }
|
protected void setUp() { // Create a frame with the test instance name as the title frame = new JFrame(getName()); pane = (JPanel)frame.getContentPane(); pane.setLayout(new FlowLayout()); pane.setBorder(new EmptyBorder(50, 50, 50, 50)); tester = ComponentTester.getTester(ThumbnailView.class); File f = new File(testImgDir, "test1.jpg" ); try { photo = PhotoInfo.addToDB( f ); } catch( PhotoNotFoundException e ) { fail( "error creating photo" ); } photo.setShootingPlace( "TESSTPLACE" ); }
| 1,111,586
|
public void registerBeanTag(String name, BeanTag tag) { templates.put(name, tag); }
|
public void registerBeanTag(String name, BeanTag tag) { templates.put(name, tag); }
| 1,111,587
|
protected void createThumbnail( Volume volume ) { log.warn( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
|
protected void createThumbnail( Volume volume ) { log.debug( "Creating thumbnail" ); ODMGXAWrapper txw = new ODMGXAWrapper(); txw.lock( this, Transaction.WRITE ); // Find the original image to use as a staring point ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_ORIGINAL ) { original = instance; txw.lock( original, Transaction.READ ); break; } } if ( original == null || original.getImageFile() == null || !original.getImageFile().exists() ) { // If there are uncorrupted instances, no thumbnail can be created log.warn( "Error - no original image was found!!!" ); txw.commit(); return; } log.warn( "Found original, reading it..." ); // Read the image BufferedImage origImage = null; try { origImage = ImageIO.read( original.getImageFile() ); } catch ( IOException e ) { log.warn( "Error reading image: " + e.getMessage() ); txw.abort(); return; } log.warn( "Done, finding name" ); // Find where to store the file in the target volume File thumbnailFile = volume.getInstanceName( this, "jpg" ); log.warn( "name = " + thumbnailFile.getName() ); // Shrink the image to desired state and save it // Find first the correct transformation for doing this int origWidth = origImage.getWidth(); int origHeight = origImage.getHeight(); int maxThumbWidth = 100; int maxThumbHeight = 100; AffineTransform xform = photovault.image.ImageXform.getFittingXform( maxThumbWidth, maxThumbHeight, prefRotation -original.getRotated(), origWidth, origHeight ); // Create the target image AffineTransformOp atOp = new AffineTransformOp( xform, AffineTransformOp.TYPE_NEAREST_NEIGHBOR ); log.warn( "Filtering..." ); BufferedImage thumbImage = atOp.filter( origImage, null ); log.warn( "done Filtering..." ); // Save it try { ImageIO.write( thumbImage, "jpg", thumbnailFile ); } catch ( IOException e ) { log.warn( "Error writing thumbnail: " + e.getMessage() ); txw.abort(); return; } // add the created instance to this persistent object ImageInstance thumbInstance = addInstance( volume, thumbnailFile, ImageInstance.INSTANCE_TYPE_THUMBNAIL ); thumbInstance.setRotated( prefRotation -original.getRotated() ); log.warn( "Loading thumbnail..." ); thumbnail = Thumbnail.createThumbnail( this, thumbnailFile ); txw.commit(); }
| 1,111,588
|
public Thumbnail getThumbnail() { log.debug( "Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance// return Thumbnail.getDefaultThumbnail(); thumbnail = Thumbnail.getDefaultThumbnail(); } return thumbnail; }
|
public Thumbnail getThumbnail() { log.debug( "getThumbnail: Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } if ( thumbnail == null ) { // Next try to create a new thumbnail instance createThumbnail(); } } if ( thumbnail == null ) { // Thumbnail creating was not successful, most probably because there is no available instance// return Thumbnail.getDefaultThumbnail(); thumbnail = Thumbnail.getDefaultThumbnail(); } return thumbnail; }
| 1,111,589
|
public boolean hasThumbnail() { log.debug( "Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } } return ( thumbnail != null ); }
|
public boolean hasThumbnail() { log.debug( "hasThumbnail: Finding thumbnail for " + uid ); if ( thumbnail == null ) { // First try to find an instance from existing instances ImageInstance original = null; for ( int n = 0; n < instances.size(); n++ ) { ImageInstance instance = (ImageInstance) instances.get( n ); if ( instance.getInstanceType() == ImageInstance.INSTANCE_TYPE_THUMBNAIL && instance.getRotated() == prefRotation ) { thumbnail = Thumbnail.createThumbnail( this, instance.getImageFile() ); break; } } } return ( thumbnail != null ); }
| 1,111,591
|
public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String title = tabs.getTitleAt(tabs.getSelectedIndex()); if (title.equals(VIEW_DPRIME) || title.equals(VIEW_HAPLOTYPES)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (title.equals(VIEW_ASSOC) || title.equals(VIEW_CHECK_PANEL) || title.equals(VIEW_TAGGER)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else if (title.equals(VIEW_PLINK)){ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); exportMenuItems[2].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (title.equals(VIEW_ASSOC)){ JTabbedPane metaAssoc = ((JTabbedPane)((HaploviewTab)tabs.getSelectedComponent()).getComponent(0)); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold() && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ htp.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } } if (title.equals(VIEW_DPRIME)){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } Chromosome.doFilter(checkPanel.getMarkerResults()); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); dPrimeDisplay.revalidate(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")) { //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } if (theData.finished){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }
|
public void stateChanged(ChangeEvent e) { if (tabs.getSelectedIndex() != -1){ window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); String title = tabs.getTitleAt(tabs.getSelectedIndex()); if (title.equals(VIEW_DPRIME) || title.equals(VIEW_HAPLOTYPES)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(true); }else if (title.equals(VIEW_ASSOC) || title.equals(VIEW_CHECK_PANEL) || title.equals(VIEW_TAGGER)){ exportMenuItems[0].setEnabled(true); exportMenuItems[1].setEnabled(false); }else if (title.equals(VIEW_PLINK)){ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); exportMenuItems[3].setEnabled(false); }else{ exportMenuItems[0].setEnabled(false); exportMenuItems[1].setEnabled(false); } //if we've adjusted the haps display thresh we need to change the haps ass panel if (title.equals(VIEW_ASSOC)){ JTabbedPane metaAssoc = ((JTabbedPane)((HaploviewTab)tabs.getSelectedComponent()).getComponent(0)); //this is the haps ass tab inside the assoc super-tab HaploAssocPanel htp = (HaploAssocPanel) metaAssoc.getComponent(1); if (htp.initialHaplotypeDisplayThreshold != Options.getHaplotypeDisplayThreshold() && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")){ htp.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } } if (title.equals(VIEW_DPRIME)){ keyMenu.setEnabled(true); }else{ keyMenu.setEnabled(false); } viewMenuItems[tabs.getSelectedIndex()].setSelected(true); if (checkPanel != null && checkPanel.changed){ //first store up the current blocks Vector currentBlocks = new Vector(); for (int blocks = 0; blocks < theData.blocks.size(); blocks++){ int thisBlock[] = (int[]) theData.blocks.elementAt(blocks); int thisBlockReal[] = new int[thisBlock.length]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlockReal[marker] = Chromosome.realIndex[thisBlock[marker]]; } currentBlocks.add(thisBlockReal); } Chromosome.doFilter(checkPanel.getMarkerResults()); //after editing the filtered marker list, needs to be prodded into //resizing correctly dPrimeDisplay.computePreferredSize(); dPrimeDisplay.colorDPrime(); dPrimeDisplay.revalidate(); hapDisplay.theData = theData; if (currentBlockDef != BLOX_CUSTOM){ changeBlocks(currentBlockDef); }else{ //adjust the blocks Vector theBlocks = new Vector(); for (int x = 0; x < currentBlocks.size(); x++){ Vector goodies = new Vector(); int currentBlock[] = (int[])currentBlocks.elementAt(x); for (int marker = 0; marker < currentBlock.length; marker++){ for (int y = 0; y < Chromosome.realIndex.length; y++){ //we only keep markers from the input that are "good" from checkdata //we also realign the input file to the current "good" subset since input is //indexed of all possible markers in the dataset if (Chromosome.realIndex[y] == currentBlock[marker]){ goodies.add(new Integer(y)); } } } int thisBlock[] = new int[goodies.size()]; for (int marker = 0; marker < thisBlock.length; marker++){ thisBlock[marker] = ((Integer)goodies.elementAt(marker)).intValue(); } if (thisBlock.length > 1){ theBlocks.add(thisBlock); } } theData.guessBlocks(BLOX_CUSTOM, theBlocks); } if (tdtPanel != null){ tdtPanel.refreshTable(); } if (taggerConfigPanel != null){ taggerConfigPanel.refreshTable(); } if(permutationPanel != null) { permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } checkPanel.changed=false; } if (hapDisplay != null && theData.blocksChanged){ try{ hapDisplay.getHaps(); if(Options.getAssocTest() != ASSOC_NONE && !Chromosome.getDataChrom().equalsIgnoreCase("chrx")) { //this is the haps ass tab inside the assoc super-tab hapAssocPanel.makeTable(new AssociationTestSet(theData.getHaplotypes(), null)); permutationPanel.setBlocksChanged(); AssociationTestSet custSet = null; if (custAssocPanel != null){ custSet = custAssocPanel.getTestSet(); } AssociationTestSet permSet = new AssociationTestSet(); permSet.cat(tdtPanel.getTestSet()); permSet.cat(hapAssocPanel.getTestSet()); permutationPanel.setTestSet( new PermutationTestSet(0,theData.getPedFile(),custSet,permSet)); } }catch(HaploViewException hv){ JOptionPane.showMessageDialog(window, hv.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } hapScroller.setViewportView(hapDisplay); theData.blocksChanged = false; } if (theData.finished){ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } }
| 1,111,592
|
public int getPreciseMarkerAt(double pos){ int where = Arrays.binarySearch(alignedPositions,pos); if (where >= 0){ return where; }else{ int left = -where-2; int right = -where-1; if (left < 0){ left = 0; right = 1; } if (right >= alignedPositions.length){ right = alignedPositions.length-1; left = alignedPositions.length-1; } if (Math.abs(alignedPositions[right] - pos) < boxRadius){ return right; }else if (Math.abs(pos - alignedPositions[left]) < boxRadius){ return left; } else{ return -left; } } }
|
public int getPreciseMarkerAt(double pos){ int where = Arrays.binarySearch(alignedPositions,pos); if (where >= 0){ return where; }else{ int left = -where-2; int right = -where-1; if (left < 0){ left = 0; right = 1; } if (right >= alignedPositions.length){ right = alignedPositions.length-1; left = alignedPositions.length-1; } if (Math.abs(alignedPositions[right] - pos) < boxRadius){ return right; }else if (Math.abs(pos - alignedPositions[left]) < boxRadius){ return left; } else{ return -1; } } }
| 1,111,593
|
public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); displayStrings = null; if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); currentSelection = new String ("Last Selection: ("); // update the cached value if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getDisplayName() + ", " + Chromosome.getMarker(boxY).getDisplayName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); currentSelection += Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName(); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); currentSelection += new String((Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1)); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); currentSelection += ") - D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime() + " LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD() + " r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared(); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"X", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); // update the cached value if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); } if (displayStrings != null){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ // clear the last selection if the mouse is left clicked lastSelection = new String (""); int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } }
|
public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); displayStrings = null; if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); currentSelection = new String ("Last Selection: ("); // update the cached value if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getDisplayName() + ", " + Chromosome.getMarker(boxY).getDisplayName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); currentSelection += Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName(); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); currentSelection += new String((Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1)); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); currentSelection += ") - D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime() + " LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD() + " r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared(); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"X", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); // update the cached value if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); } if (displayStrings != null){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ // clear the last selection if the mouse is left clicked lastSelection = new String (""); int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } }
| 1,111,594
|
public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); displayStrings = null; if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); currentSelection = new String ("Last Selection: ("); // update the cached value if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getDisplayName() + ", " + Chromosome.getMarker(boxY).getDisplayName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); currentSelection += Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName(); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); currentSelection += new String((Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1)); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); currentSelection += ") - D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime() + " LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD() + " r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared(); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"X", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); // update the cached value if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); } if (displayStrings != null){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ // clear the last selection if the mouse is left clicked lastSelection = new String (""); int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } }
|
public void mousePressed (MouseEvent e) { Rectangle blockselector = new Rectangle(clickXShift-boxRadius,clickYShift - boxRadius, (int)alignedPositions[alignedPositions.length-1]+boxSize, boxSize); //if users right clicks & holds, pop up the info if ((e.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK){ Graphics g = getGraphics(); g.setFont(popupFont); FontMetrics metrics = g.getFontMetrics(); DPrimeTable dPrimeTable = theData.dpTable; final int clickX = e.getX(); final int clickY = e.getY(); final int boxX, boxY; boxX = getPreciseMarkerAt(clickX - clickXShift - (clickY-clickYShift)); boxY = getPreciseMarkerAt(clickX - clickXShift + (clickY-clickYShift)); displayStrings = null; if ((boxX >= lowX && boxX <= highX) && (boxY > boxX && boxY < highY) && !(wmInteriorRect.contains(clickX,clickY))){ if (dPrimeTable.getLDStats(boxX,boxY) != null){ double[] freqs = dPrimeTable.getLDStats(boxX,boxY).getFreqs(); displayStrings = new Vector(); currentSelection = new String ("Last Selection: ("); // update the cached value if (theData.infoKnown){ displayStrings.add(new String ("(" +Chromosome.getMarker(boxX).getDisplayName() + ", " + Chromosome.getMarker(boxY).getDisplayName() + ")")); double sep = (int)((Chromosome.getMarker(boxY).getPosition() - Chromosome.getMarker(boxX).getPosition())/100); sep /= 10; displayStrings.add(new Double(sep).toString() + " kb"); currentSelection += Chromosome.getMarker(boxX).getName() + ", " + Chromosome.getMarker(boxY).getName(); }else{ displayStrings.add(new String("(" + (Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1) + ")")); currentSelection += new String((Chromosome.realIndex[boxX]+1) + ", " + (Chromosome.realIndex[boxY]+1)); } displayStrings.add(new String ("D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime())); displayStrings.add(new String ("LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD())); displayStrings.add( new String ("r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared())); displayStrings.add(new String ("D' conf. bounds: " + dPrimeTable.getLDStats(boxX,boxY).getConfidenceLow() + "-" + dPrimeTable.getLDStats(boxX,boxY).getConfidenceHigh())); currentSelection += ") - D': " + dPrimeTable.getLDStats(boxX,boxY).getDPrime() + " LOD: " + dPrimeTable.getLDStats(boxX,boxY).getLOD() + " r-squared: " + dPrimeTable.getLDStats(boxX,boxY).getRSquared(); //get the alleles for the 4 two-marker haplotypes String[] alleleStrings = new String[4]; String[] alleleMap = {"X", "A","C","G","T"}; if (freqs[0] + freqs[1] > freqs[2] + freqs[3]){ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; }else{ alleleStrings[0] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[1] = alleleMap[Chromosome.getMarker(boxX).getMinor()]; alleleStrings[2] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; alleleStrings[3] = alleleMap[Chromosome.getMarker(boxX).getMajor()]; } if (freqs[0] + freqs[3] > freqs[1] + freqs[2]){ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; }else{ alleleStrings[0] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; alleleStrings[1] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[2] += alleleMap[Chromosome.getMarker(boxY).getMajor()]; alleleStrings[3] += alleleMap[Chromosome.getMarker(boxY).getMinor()]; } displayStrings.add(new String("Frequencies:")); for (int i = 0; i < 4; i++){ if (freqs[i] > 1.0E-10){ displayStrings.add( new String(alleleStrings[i] + " = " + Math.rint(1000 * freqs[i])/10 + "%")); } } } } else if (blockselector.contains(clickX, clickY)){ int marker = getPreciseMarkerAt(clickX - clickXShift); displayStrings = new Vector(); currentSelection = new String ("Last Selection: "); // update the cached value if (theData.infoKnown){ displayStrings.add(new String (Chromosome.getMarker(marker).getDisplayName())); currentSelection += Chromosome.getMarker(marker).getName(); }else{ displayStrings.add(new String("Marker " + (Chromosome.realIndex[marker]+1))); currentSelection += new String("Marker " + (Chromosome.realIndex[marker]+1)); } displayStrings.add(new String ("MAF: " + Chromosome.getMarker(marker).getMAF())); if (Chromosome.getMarker(marker).getExtra() != null) displayStrings.add(new String (Chromosome.getMarker(marker).getExtra())); currentSelection += new String (", MAF: " + Chromosome.getMarker(marker).getMAF()); } if (displayStrings != null){ int strlen = 0; for (int x = 0; x < displayStrings.size(); x++){ if (strlen < metrics.stringWidth((String)displayStrings.elementAt(x))){ strlen = metrics.stringWidth((String)displayStrings.elementAt(x)); } } //edge shifts prevent window from popping up partially offscreen int visRightBound = (int)(getVisibleRect().getWidth() + getVisibleRect().getX()); int visBotBound = (int)(getVisibleRect().getHeight() + getVisibleRect().getY()); int rightEdgeShift = 0; if (clickX + strlen + popupLeftMargin +5 > visRightBound){ rightEdgeShift = clickX + strlen + popupLeftMargin + 10 - visRightBound; } int botEdgeShift = 0; if (clickY + displayStrings.size()*metrics.getHeight()+10 > visBotBound){ botEdgeShift = clickY + displayStrings.size()*metrics.getHeight()+15 - visBotBound; } int smallDataVertSlop = 0; if (getPreferredSize().getWidth() < getVisibleRect().width && theData.infoKnown){ smallDataVertSlop = (int)(getVisibleRect().height - getPreferredSize().getHeight())/2; } popupDrawRect = new Rectangle(clickX-rightEdgeShift, clickY-botEdgeShift+smallDataVertSlop, strlen+popupLeftMargin+5, displayStrings.size()*metrics.getHeight()+10); repaint(); } }else if ((e.getModifiers() & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK){ // clear the last selection if the mouse is left clicked lastSelection = new String (""); int x = e.getX(); int y = e.getY(); if (blockselector.contains(x,y)){ setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR)); blockStartX = x; } } }
| 1,111,595
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 170, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
| 1,111,597
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
| 1,111,598
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ triangle.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
| 1,111,599
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
|
public void paintComponent(Graphics g){ DPrimeTable dPrimeTable = theData.dpTable; if (Chromosome.getSize() < 2){ //if there zero or only one valid marker return; } Vector blocks = theData.blocks; Rectangle visRect = getVisibleRect(); //deal with zooming if (chartSize.getWidth() > (3*visRect.width)){ showWM = true; }else{ showWM = false; } boolean printValues = true; if (zoomLevel != 0 || Options.getPrintWhat() == LD_NONE){ printValues = false; } printWhat = Options.getPrintWhat(); Graphics2D g2 = (Graphics2D) g; Dimension size = getSize(); Dimension pref = getPreferredSize(); g2.setColor(BG_GREY); //if it's a big dataset, resize properly, if it's small make sure to fill whole background if (size.height < pref.height){ g2.fillRect(0,0,pref.width,pref.height); setSize(pref); }else{ g2.fillRect(0,0,size.width, size.height); } g2.setColor(Color.black); //okay so this dumb if block is to prevent the ugly repainting //bug when loading markers after the data are already being displayed, //results in a little off-centering for small datasets, but not too bad. if (!forExport){ if (!theData.infoKnown){ g2.translate((size.width - pref.width) / 2, (size.height - pref.height) / 2); } else { g2.translate((size.width - pref.width) / 2, 0); } } FontMetrics boxFontMetrics = g2.getFontMetrics(boxFont); int diamondX[] = new int[4]; int diamondY[] = new int[4]; Polygon diamond; double lineSpan = alignedPositions[alignedPositions.length-1] - alignedPositions[0]; long minpos = Chromosome.getMarker(0).getPosition(); long maxpos = Chromosome.getMarker(Chromosome.getSize()-1).getPosition(); double spanpos = maxpos - minpos; //See http://www.hapmap.org/cgi-perl/gbrowse/gbrowse_img //for more info on GBrowse img. int imgHeight = 0; if (Options.isGBrowseShown() && Chromosome.getDataChrom() != null && !Chromosome.getDataChrom().equalsIgnoreCase("none")){ g2.drawImage(gBrowseImage,H_BORDER-GBROWSE_MARGIN,V_BORDER,this); imgHeight = gBrowseImage.getHeight(this) + TRACK_GAP; // get height so we can shift everything down } left = H_BORDER; top = V_BORDER + imgHeight; // push the haplotype display down to make room for gbrowse image. if (forExport){ left -= exportStart * boxSize; } FontMetrics metrics; int ascent; g2.setFont(boldMarkerNameFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); //the following values are the bounds on the boxes we want to //display given that the current window is 'visRect' lowX = getBoundaryMarker(visRect.x-clickXShift-(visRect.y +visRect.height-clickYShift)) - 1; highX = getBoundaryMarker(visRect.x + visRect.width); lowY = getBoundaryMarker((visRect.x-clickXShift)+(visRect.y-clickYShift)) - 1; highY = getBoundaryMarker((visRect.x-clickXShift+visRect.width) + (visRect.y-clickYShift+visRect.height)); if (lowX < 0) { lowX = 0; } if (highX > Chromosome.getSize()-1){ highX = Chromosome.getSize()-1; } if (lowY < lowX+1){ lowY = lowX+1; } if (highY > Chromosome.getSize()){ highY = Chromosome.getSize(); } if (forExport){ lowX = exportStart; lowY = exportStart; highX = exportStop; highY = exportStop+1; } if (theData.trackExists){ //draw the analysis track above where the marker positions will be marked JFreeChart jfc = ChartFactory.createXYLineChart(null,null,null, theData.analysisTracks, PlotOrientation.VERTICAL,false,false,false); //customise the analysis track XYPlot xyp = (XYPlot)jfc.getPlot(); //no x axis, since it takes up too much space. xyp.getDomainAxis().setAxisLineVisible(false); xyp.getDomainAxis().setTickLabelsVisible(false); xyp.getDomainAxis().setTickMarksVisible(false); //x range must align with markers xyp.getDomainAxis().setRange(minpos,maxpos); //size of the axis and graph inset double axisWidth = xyp.getRangeAxis(). reserveSpace(g2,xyp,new Rectangle(0,TRACK_HEIGHT),RectangleEdge.LEFT,null).getLeft(); RectangleInsets insets = xyp.getInsets(); jfc.setBackgroundPaint(BG_GREY); BufferedImage bi = jfc.createBufferedImage( (int)(lineSpan + axisWidth + insets.getLeft() + insets.getRight()),TRACK_HEIGHT); //hide the axis in the margin so everything lines up. g2.drawImage(bi,(int)(left - axisWidth - insets.getLeft()),top,this); top += TRACK_HEIGHT + TRACK_GAP; } if (theData.infoKnown) { Color green = new Color(0, 127, 0); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //// draw the marker locations g2.setStroke(thinnerStroke); g2.setColor(Color.white); g2.fill(new Rectangle2D.Double(left+1, top+1, lineSpan-1, TICK_HEIGHT-1)); g2.setColor(Color.black); g2.draw(new Rectangle2D.Double(left, top, lineSpan, TICK_HEIGHT)); for (int i = 0; i < Chromosome.getSize(); i++){ double pos = (Chromosome.getMarker(i).getPosition() - minpos) / spanpos; double xx = left + lineSpan*pos; // if we're zoomed, use the line color to indicate whether there is extra data available // (since the marker names are not displayed when zoomed) if (Chromosome.getMarker(i).getExtra() != null) g2.setColor(green); //draw tick g2.setStroke(thickerStroke); g2.draw(new Line2D.Double(xx, top, xx, top + TICK_HEIGHT)); if (Chromosome.getMarker(i).getExtra() != null) g2.setStroke(thickerStroke); else g2.setStroke(thinnerStroke); //draw connecting line g2.draw(new Line2D.Double(xx, top + TICK_HEIGHT, left + alignedPositions[i], top+TICK_BOTTOM)); if (theHV != null){ //draw a star with funny numbers which conform to the golden ratio and make a nice pentagram if (Chromosome.getMarker(i).getDisplayName().equals(theHV.getChosenMarker())){ float cornerx = (float)xx-12.0f; float cornery = top-2; float xpoints[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; GeneralPath star = new GeneralPath(GeneralPath.WIND_NON_ZERO,xpoints.length); star.moveTo(xpoints[0],ypoints[0]); for (int index = 1; index < xpoints.length; index++){ star.lineTo(xpoints[index],ypoints[index]); } star.closePath(); g2.fill(star); cornerx = (float)alignedPositions[i] + left - 12; cornery = top + TICK_BOTTOM - 5; float xpoints1[] = {cornerx,cornerx+24.0f,cornerx+4.6f,cornerx+12.0f,cornerx+19.4f}; float ypoints1[] = {cornery,cornery,cornery+14.1f,cornery-8.7f,cornery+14.1f}; star.moveTo(xpoints1[0],ypoints1[0]); for (int index = 1; index < xpoints1.length; index++){ star.lineTo(xpoints1[index],ypoints1[index]); } star.closePath(); g2.fill(star); } } g2.setColor(Color.black); } top += TICK_BOTTOM + TICK_HEIGHT; //// draw the marker names if (printMarkerNames){ widestMarkerName = metrics.stringWidth(Chromosome.getMarker(0).getDisplayName()); for (int x = 1; x < Chromosome.getSize(); x++) { int thiswide = metrics.stringWidth(Chromosome.getMarker(x).getDisplayName()); if (thiswide > widestMarkerName) widestMarkerName = thiswide; } g2.translate(left, top + widestMarkerName); g2.rotate(-Math.PI / 2.0); for (int x = 0; x < Chromosome.getSize(); x++) { if (theData.isInBlock[x]){ g2.setFont(boldMarkerNameFont); }else{ g2.setFont(markerNameFont); } if (Chromosome.getMarker(x).getExtra() != null) g2.setColor(green); g2.drawString(Chromosome.getMarker(x).getDisplayName(),(float)TEXT_GAP, (float)alignedPositions[x] + ascent/3); g2.setColor(Color.black); } g2.rotate(Math.PI / 2.0); g2.translate(-left, -(top + widestMarkerName)); // move everybody down top += widestMarkerName + TEXT_GAP; } g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } top += blockDispHeight; //// draw the marker numbers if (printMarkerNames){ g2.setFont(markerNumFont); metrics = g2.getFontMetrics(); ascent = metrics.getAscent(); for (int x = 0; x < Chromosome.getSize(); x++) { String mark = String.valueOf(Chromosome.realIndex[x] + 1); g2.drawString(mark, (float)(left + alignedPositions[x] - metrics.stringWidth(mark)/2), (float)(top + ascent)); } top += boxRadius/2; // give a little space between numbers and boxes } //clickxshift and clickyshift are used later to translate from x,y coords //to the pair of markers comparison at those coords if (!(theData.infoKnown)){ clickXShift = left + (size.width-pref.width)/2; clickYShift = top + (size.height - pref.height)/2; } else { clickXShift = left + (size.width-pref.width)/2; clickYShift = top; } // draw table column by column for (int x = lowX; x < highX; x++) { //always draw the fewest possible boxes if (lowY < x+1){ lowY = x+1; } for (int y = lowY; y < highY; y++) { if (dPrimeTable.getLDStats(x,y) == null){ continue; } double d = dPrimeTable.getLDStats(x,y).getDPrime(); double r = dPrimeTable.getLDStats(x,y).getRSquared(); //double l = dPrimeTable.getLDStats(x,y).getLOD(); Color boxColor = dPrimeTable.getLDStats(x,y).getColor(); // draw markers above int xx = left + (int)((alignedPositions[x] + alignedPositions[y])/2); int yy = top + (int)((alignedPositions[y] - alignedPositions[x]) / 2); diamondX[0] = xx; diamondY[0] = yy - boxRadius; diamondX[1] = xx + boxRadius; diamondY[1] = yy; diamondX[2] = xx; diamondY[2] = yy + boxRadius; diamondX[3] = xx - boxRadius; diamondY[3] = yy; diamond = new Polygon(diamondX, diamondY, 4); g2.setColor(boxColor); g2.fillPolygon(diamond); if(printValues){ g2.setFont(boxFont); ascent = boxFontMetrics.getAscent(); int val; if (printWhat == D_PRIME){ val = (int) (d * 100); }else if (printWhat == R_SQ){ val = (int) (r * 100); }else{ val = 100; } if (boxColor.getGreen() < 175 && boxColor.getBlue() < 175 && boxColor.getRed() < 175){ g2.setColor(Color.white); }else{ g2.setColor((val < 50) ? Color.gray : Color.black); } if (val != 100) { String valu = String.valueOf(val); int widf = boxFontMetrics.stringWidth(valu); g.drawString(valu, xx - widf/2, yy + ascent/2); } } } } //highlight blocks g2.setFont(markerNameFont); ascent = g2.getFontMetrics().getAscent(); //g.setColor(new Color(153,255,153)); g2.setColor(Color.black); //g.setColor(new Color(51,153,51)); for (int i = 0; i < blocks.size(); i++){ int[] theBlock = (int[])blocks.elementAt(i); int first = theBlock[0]; int last = theBlock[theBlock.length-1]; //big vee around whole thing g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first] - boxRadius, top, left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius)); g2.draw(new Line2D.Double(left + (alignedPositions[first] + alignedPositions[last])/2, top + (alignedPositions[last] - alignedPositions[first])/2 + boxRadius, left + alignedPositions[last] + boxRadius, top)); for (int j = first; j < last; j++){ g2.setStroke(fatStroke); if (theData.isInBlock[j]){ g2.draw(new Line2D.Double(left+alignedPositions[j]-boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); }else{ g2.draw(new Line2D.Double(left + alignedPositions[j] + boxSize/2, top-blockDispHeight, left+alignedPositions[j+1]-boxSize/2, top-blockDispHeight)); g2.setStroke(dashedFatStroke); g2.draw(new Line2D.Double(left+alignedPositions[j] - boxSize/2, top-blockDispHeight, left+alignedPositions[j] + boxSize/2, top-blockDispHeight)); } } //cap off the end of the block g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left+alignedPositions[last]-boxSize/2, top-blockDispHeight, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); //lines to connect to block display g2.setStroke(fatStroke); g2.draw(new Line2D.Double(left + alignedPositions[first]-boxSize/2, top-1, left+alignedPositions[first]-boxSize/2, top-blockDispHeight)); g2.draw(new Line2D.Double(left+alignedPositions[last]+boxSize/2, top-1, left+alignedPositions[last]+boxSize/2, top-blockDispHeight)); if (printMarkerNames){ String labelString = new String ("Block " + (i+1)); if (theData.infoKnown){ long blockSize = Chromosome.getMarker(last).getPosition() - Chromosome.getMarker(first).getPosition(); labelString += " (" + blockSize/1000 + " kb)"; } g2.drawString(labelString, (float)(left+alignedPositions[first]-boxSize/2+TEXT_GAP), (float)(top-boxSize/3)); } } g2.setStroke(thickerStroke); if (showWM && !forExport){ //dataset is big enough to require worldmap if (wmMaxWidth == 0){ wmMaxWidth = visRect.width/3; } double scalefactor; scalefactor = (double)(chartSize.width)/wmMaxWidth; double prefBoxSize = boxSize/(scalefactor*((double)wmMaxWidth/(double)(wmMaxWidth))); //stick WM_BD in the middle of the blank space at the top of the worldmap final int WM_BD_GAP = (int)(infoHeight/(scalefactor*2)); final int WM_BD_HEIGHT = 2; CompoundBorder wmBorder = new CompoundBorder(BorderFactory.createRaisedBevelBorder(), BorderFactory.createLoweredBevelBorder()); if (noImage){ //first time through draw a worldmap if dataset is big: worldmap = new BufferedImage((int)(chartSize.width/scalefactor)+wmBorder.getBorderInsets(this).left*2, (int)(chartSize.height/scalefactor)+wmBorder.getBorderInsets(this).top*2, BufferedImage.TYPE_3BYTE_BGR); Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(1,1,worldmap.getWidth()-1,worldmap.getHeight()-1); //make a pretty border gw2.setColor(Color.black); wmBorder.paintBorder(this,gw2,0,0,worldmap.getWidth(),worldmap.getHeight()); wmInteriorRect = wmBorder.getInteriorRectangle(this,0,0,worldmap.getWidth(), worldmap.getHeight()); float[] smallDiamondX = new float[4]; float[] smallDiamondY = new float[4]; GeneralPath gp; for (int x = 0; x < Chromosome.getSize()-1; x++){ for (int y = x+1; y < Chromosome.getSize(); y++){ if (dPrimeTable.getLDStats(x,y) == null){ continue; } double xx = ((alignedPositions[y] + alignedPositions[x])/(scalefactor*2)) + wmBorder.getBorderInsets(this).left; double yy = ((alignedPositions[y] - alignedPositions[x] + infoHeight*2)/(scalefactor*2)) + wmBorder.getBorderInsets(this).top; smallDiamondX[0] = (float)xx; smallDiamondY[0] = (float)(yy - prefBoxSize/2); smallDiamondX[1] = (float)(xx + prefBoxSize/2); smallDiamondY[1] = (float)yy; smallDiamondX[2] = (float)xx; smallDiamondY[2] = (float)(yy + prefBoxSize/2); smallDiamondX[3] = (float)(xx - prefBoxSize/2); smallDiamondY[3] = (float)yy; gp = new GeneralPath(GeneralPath.WIND_EVEN_ODD, smallDiamondX.length); gp.moveTo(smallDiamondX[0],smallDiamondY[0]); for (int i = 1; i < smallDiamondX.length; i++){ gp.lineTo(smallDiamondX[i], smallDiamondY[i]); } gp.closePath(); gw2.setColor(dPrimeTable.getLDStats(x,y).getColor()); gw2.fill(gp); } } noImage = false; } //draw block display in worldmap Graphics gw = worldmap.getGraphics(); Graphics2D gw2 = (Graphics2D)(gw); gw2.setColor(BG_GREY); gw2.fillRect(wmBorder.getBorderInsets(this).left, wmBorder.getBorderInsets(this).top+WM_BD_GAP, wmInteriorRect.width, WM_BD_HEIGHT); gw2.setColor(Color.black); boolean even = true; for (int i = 0; i < blocks.size(); i++){ int first = ((int[])blocks.elementAt(i))[0]; int last = ((int[])blocks.elementAt(i))[((int[])blocks.elementAt(i)).length-1]; int voffset; if (even){ voffset = 0; }else{ voffset = WM_BD_HEIGHT/2; } gw2.fillRect(wmBorder.getBorderInsets(this).left - (int)prefBoxSize/2 + (int)(alignedPositions[first]/scalefactor), wmBorder.getBorderInsets(this).top+voffset+WM_BD_GAP, (int)(prefBoxSize + (alignedPositions[last] - alignedPositions[first])/scalefactor), WM_BD_HEIGHT/2); even = !even; } wmResizeCorner = new Rectangle(visRect.x + worldmap.getWidth() - (worldmap.getWidth()-wmInteriorRect.width)/2, visRect.y + visRect.height - worldmap.getHeight(), (worldmap.getWidth()-wmInteriorRect.width)/2, (worldmap.getHeight() -wmInteriorRect.height)/2); g2.drawImage(worldmap,visRect.x, visRect.y + visRect.height - worldmap.getHeight(), this); wmInteriorRect.x = visRect.x + (worldmap.getWidth() - wmInteriorRect.width)/2; wmInteriorRect.y = visRect.y+visRect.height-worldmap.getHeight() + (worldmap.getHeight() - wmInteriorRect.height)/2; //draw the outline of the viewport g2.setColor(Color.black); double hRatio = wmInteriorRect.getWidth()/pref.getWidth(); double vRatio = wmInteriorRect.getHeight()/pref.getHeight(); int hBump = worldmap.getWidth()-wmInteriorRect.width; int vBump = worldmap.getHeight()-wmInteriorRect.height; //bump a few pixels to avoid drawing on the border g2.drawRect((int)(visRect.x*hRatio)+hBump/2+visRect.x, (int)(visRect.y*vRatio)+vBump/2+(visRect.y + visRect.height - worldmap.getHeight()), (int)(visRect.width*hRatio), (int)(visRect.height*vRatio)); } //see if the user has right-clicked to popup some marker info if(popupDrawRect != null){ //dumb bug where little datasets popup the box in the wrong place int smallDatasetSlopH = 0; int smallDatasetSlopV = 0; if (pref.getHeight() < visRect.height){ smallDatasetSlopV = (int)(visRect.height - pref.getHeight())/2; } if (pref.getWidth() < visRect.width){ smallDatasetSlopH = (int)(visRect.width - pref.getWidth())/2; } g2.setColor(Color.white); g2.fillRect(popupDrawRect.x+1-smallDatasetSlopH, popupDrawRect.y+1-smallDatasetSlopV, popupDrawRect.width-1, popupDrawRect.height-1); g2.setColor(Color.black); g2.drawRect(popupDrawRect.x-smallDatasetSlopH, popupDrawRect.y-smallDatasetSlopV, popupDrawRect.width, popupDrawRect.height); g.setFont(popupFont); for (int x = 0; x < displayStrings.size(); x++){ g.drawString((String)displayStrings.elementAt(x),popupDrawRect.x + popupLeftMargin-smallDatasetSlopH, popupDrawRect.y+((x+1)*metrics.getHeight())-smallDatasetSlopV); } } // draw the cached last right-click selection // The purpose of testing for empty string is just to avoid an 2-unit empty white box if (lastSelection != null){ if ((zoomLevel == 0) && (!lastSelection.equals("")) && (!forExport)) { g2.setFont(boxFont); // a bit extra on all side int last_descent = g2.getFontMetrics().getDescent(); int last_box_x = (visRect.x + LAST_SELECTION_LEFT) - 2; int last_box_y = (visRect.y - g2.getFontMetrics().getHeight() + LAST_SELECTION_TOP + last_descent) - 1 ; int last_box_width = g2.getFontMetrics().stringWidth(lastSelection) + 4; int last_box_height = g2.getFontMetrics().getHeight() + 2; g2.setColor(Color.white); g2.fillRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.setColor(Color.black); g2.drawRect(last_box_x, last_box_y, last_box_width, last_box_height); g2.drawString(lastSelection, LAST_SELECTION_LEFT + visRect.x, LAST_SELECTION_TOP + visRect.y); } } //see if we're drawing a worldmap resize rect if (resizeWMRect != null){ g2.setColor(Color.black); g2.drawRect(resizeWMRect.x, resizeWMRect.y, resizeWMRect.width, resizeWMRect.height); } //see if we're drawing a block selector rect if (blockRect != null){ g2.setColor(Color.black); g2.setStroke(dashedThinStroke); g2.drawRect(blockRect.x, blockRect.y, blockRect.width, blockRect.height); } }
| 1,111,600
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
| 1,111,602
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(tp.getSelectedColumnIndex()); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
| 1,111,603
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
| 1,111,604
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { JOptionPane.showMessageDialog(dbt, ex.getMessage()); } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
|
public void actionPerformed(ActionEvent evt) { if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_PLAYPEN)) { List items = pp.getSelectedItems(); if (items.size() > 1) { int decision = JOptionPane.showConfirmDialog(pp, "Are you sure you want to delete the " +items.size()+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = items.iterator(); while (it.hasNext()) { Selectable item = (Selectable) it.next(); if (item instanceof TablePane) { TablePane tp = (TablePane) item; int colidx; if ( (colidx = tp.getSelectedColumnIndex()) >= 0) { // a column in the selected table try { tp.getModel().removeColumn(colidx); // FIXME: loop inside here to support multiple column deletion? } catch (LockedColumnException ex) { JOptionPane.showMessageDialog((JComponent) item, ex.getMessage()); } } else { // the whole table pp.db.removeChild(tp.getModel()); if (logger.isDebugEnabled()) { logger.debug("removing element from tableNames set: " + tp.getModel().getTableName()); logger.debug("before delete: " + pp.tableNames.toArray()); } pp.tableNames.remove(tp.getModel().getTableName().toLowerCase()); if (logger.isDebugEnabled()) { logger.debug("after delete: " + pp.tableNames.toArray()); } } } else if (item instanceof Relationship) { Relationship r = (Relationship) item; SQLRelationship sr = r.getModel(); sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); } else { JOptionPane.showMessageDialog((JComponent) item, "The selected item type is not recognised"); } } } else if (evt.getActionCommand().equals(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE)) { TreePath [] selections = dbt.getSelectionPaths(); if (selections.length > 1) { int decision = JOptionPane.showConfirmDialog(dbt, "Are you sure you want to delete the " +selections.length+" selected items?", "Multiple Delete", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } Iterator it = Arrays.asList(selections).iterator(); while (it.hasNext()) { TreePath tp = (TreePath) it.next(); SQLObject so = (SQLObject) tp.getLastPathComponent(); if (so instanceof SQLTable) { SQLTable st = (SQLTable) so; pp.db.removeChild(st); pp.tableNames.remove(st.getTableName().toLowerCase()); } else if (so instanceof SQLColumn) { try { SQLColumn sc = (SQLColumn)so; SQLTable st = sc.getParentTable(); st.removeColumn(sc); } catch (LockedColumnException ex) { int decision = JOptionPane.showConfirmDialog(dbt, "Could not delete the column " + sc.getName() + " because it is part of a relationship key. Continue" + " deleting of other selected items?", "Column is Locked", JOptionPane.YES_NO_OPTION); if (decision == JOptionPane.NO_OPTION) { return; } } } else if (so instanceof SQLRelationship) { SQLRelationship sr = (SQLRelationship) so; sr.getPkTable().removeExportedKey(sr); sr.getFkTable().removeImportedKey(sr); // FIXME: do we need to do some removeDependencies() stuff here? } else { JOptionPane.showMessageDialog(dbt, "The selected SQLObject type is not recognised: " + so.getClass().getName()); } } } else { // unknown action command source, do nothing } }
| 1,111,605
|
public double chsoneCalculate(double[] bins, double[] ebins, int nbins, int knstrn) throws CheckDataException{ double prob, df, chsq, temp; df = nbins - knstrn ; chsq = 0.0 ; for (int j = 1 ; j <= nbins ; j ++ ) { if (ebins [j ]<= 0.0 ) throw new CheckDataException("Bad expected number in chsone" ); temp = bins[j]- ebins[j]; chsq += temp * temp / ebins [j]; } prob = MathUtil.gammq (0.5 * df, 0.5 * chsq ); return prob; //this._chisq = chsq; }
|
public double chsoneCalculate(double[] bins, double[] ebins, int nbins, int knstrn){ double prob, df, chsq, temp; df = nbins - knstrn ; chsq = 0.0 ; for (int j = 1 ; j <= nbins ; j ++ ) { if (ebins [j ]<= 0.0 ) throw new CheckDataException("Bad expected number in chsone" ); temp = bins[j]- ebins[j]; chsq += temp * temp / ebins [j]; } prob = MathUtil.gammq (0.5 * df, 0.5 * chsq ); return prob; //this._chisq = chsq; }
| 1,111,607
|
public double chsoneCalculate(double[] bins, double[] ebins, int nbins, int knstrn) throws CheckDataException{ double prob, df, chsq, temp; df = nbins - knstrn ; chsq = 0.0 ; for (int j = 1 ; j <= nbins ; j ++ ) { if (ebins [j ]<= 0.0 ) throw new CheckDataException("Bad expected number in chsone" ); temp = bins[j]- ebins[j]; chsq += temp * temp / ebins [j]; } prob = MathUtil.gammq (0.5 * df, 0.5 * chsq ); return prob; //this._chisq = chsq; }
|
public double chsoneCalculate(double[] bins, double[] ebins, int nbins, int knstrn) throws CheckDataException{ double prob, df, chsq, temp; df = nbins - knstrn ; chsq = 0.0 ; for (int j = 1 ; j <= nbins ; j ++ ) { if (ebins [j ]<= 0.0 ) throw new CheckDataException("Bad expected number in chsone" ); temp = bins[j]- ebins[j]; chsq += temp * temp / ebins [j]; } prob = MathUtil.gammq (0.5 * df, 0.5 * chsq ); return prob; //this._chisq = chsq; }
| 1,111,608
|
private double getObsHET(int het, int hom){ double obsHET = het/(het+hom+0.0); return obsHET; }
|
private double getObsHET(int het, int hom){ double obsHET; if (het+hom == 0){ obsHET = 0; }else{ obsHET = het/(het+hom+0.0); } return obsHET; }
| 1,111,609
|
private double getPValue(Hashtable parentHom, int parentHet){ //ie: 11 13 31 33 -> homA =1 homB = 1 parentHet=2 int homA=0, homB=0, num; double pvalue=0; Enumeration enu = parentHom.elements(); while(enu.hasMoreElements()){ num = Integer.parseInt((String)enu.nextElement()); if(homA>0) homB = num; else homA = num; } //caculate p value from homA, parentHet and homB // using hw //System.out.println("homA="+homA+" homB="+homB+" parentHet="+parentHet); //HW hw = new HW((double)homA, (double)parentHet, (double)homB); try{ //hw.caculate(); pvalue = hwCalculate((double)homA, (double)parentHet, (double)homB); } catch(CheckDataException e){ System.out.println("input data error in caculating p value"); System.out.println(e.getMessage()); } return pvalue; }
|
private double getPValue(Hashtable parentHom, int parentHet){ //ie: 11 13 31 33 -> homA =1 homB = 1 parentHet=2 int homA=0, homB=0, num; double pvalue=0; Enumeration enu = parentHom.elements(); while(enu.hasMoreElements()){ num = Integer.parseInt((String)enu.nextElement()); if(homA>0) homB = num; else homA = num; } //caculate p value from homA, parentHet and homB // using hw //System.out.println("homA="+homA+" homB="+homB+" parentHet="+parentHet); //HW hw = new HW((double)homA, (double)parentHet, (double)homB); //hw.caculate(); pvalue = hwCalculate((double)homA, (double)parentHet, (double)homB); } catch(CheckDataException e){ System.out.println("input data error in caculating p value"); System.out.println(e.getMessage()); } return pvalue; }
| 1,111,610
|
private double getPValue(Hashtable parentHom, int parentHet){ //ie: 11 13 31 33 -> homA =1 homB = 1 parentHet=2 int homA=0, homB=0, num; double pvalue=0; Enumeration enu = parentHom.elements(); while(enu.hasMoreElements()){ num = Integer.parseInt((String)enu.nextElement()); if(homA>0) homB = num; else homA = num; } //caculate p value from homA, parentHet and homB // using hw //System.out.println("homA="+homA+" homB="+homB+" parentHet="+parentHet); //HW hw = new HW((double)homA, (double)parentHet, (double)homB); try{ //hw.caculate(); pvalue = hwCalculate((double)homA, (double)parentHet, (double)homB); } catch(CheckDataException e){ System.out.println("input data error in caculating p value"); System.out.println(e.getMessage()); } return pvalue; }
|
private double getPValue(Hashtable parentHom, int parentHet){ //ie: 11 13 31 33 -> homA =1 homB = 1 parentHet=2 int homA=0, homB=0, num; double pvalue=0; Enumeration enu = parentHom.elements(); while(enu.hasMoreElements()){ num = Integer.parseInt((String)enu.nextElement()); if(homA>0) homB = num; else homA = num; } //caculate p value from homA, parentHet and homB // using hw //System.out.println("homA="+homA+" homB="+homB+" parentHet="+parentHet); //HW hw = new HW((double)homA, (double)parentHet, (double)homB); try{ //hw.caculate(); pvalue = hwCalculate((double)homA, (double)parentHet, (double)homB); } catch(CheckDataException e){ System.out.println("input data error in caculating p value"); System.out.println(e.getMessage()); } return pvalue; }
| 1,111,611
|
private double getPreHET(Hashtable count){ int sumsq=0, sum=0, num=0; Enumeration enu = count.elements(); while(enu.hasMoreElements()){ num = Integer.parseInt((String)enu.nextElement()); sumsq += num*num; sum += num; } double preHet = 1.0 - (sumsq/((sum*sum)+0.0)); return preHet; }
|
private double getPreHET(Hashtable count){ int sumsq=0, sum=0, num=0; Enumeration enu = count.elements(); while(enu.hasMoreElements()){ num = Integer.parseInt((String)enu.nextElement()); sumsq += num*num; sum += num; } double preHet; if (sum == 0){ preHet = 0; }else{ preHet = 1.0 - (sumsq/((sum*sum)+0.0)); } return preHet; }
| 1,111,612
|
private double hwCalculate(double obsAA, double obsAB, double obsBB) throws CheckDataException{ double obs[]={0.0, obsAA, obsAB, obsBB}; double expect[]={0.0, 0.0, 0.0, 0.0}; double sum_obs; //double csq, df, sum_expect; double prob, p, start, end; double best_prob =-1.0; double best_p=0; sum_obs = obs [1 ]+ obs [2 ]+ obs [3 ]; for (p = 0.01 ; p <= .99 ; p += .01 ) { expect [1 ]= sum_obs * p * p ; expect [2 ]= sum_obs * 2.0 * p * (1.0 - p); expect [3 ]= sum_obs * (1.0 - p) * (1.0 - p); //Chsone chsone = new Chsone(obs , expect , 3 , 1); //chsone.caculate(); //prob = chsone.getPvalue(); prob = chsoneCalculate(obs,expect,3,1); if (prob > best_prob ) { best_prob = prob ; best_p = p ; } } start = (best_p - .025 > .001)? (best_p - .025): .001 ; end = (best_p + .025 < .999)? (best_p + .025): .999 ; for (p = start ; p <= end ; p += .001 ) { expect [1 ]= sum_obs * p * p ; expect [2 ]= sum_obs * 2.0 * p * (1.0 - p) ; expect [3 ]= sum_obs * (1.0 - p) * (1.0 - p) ; //Chsone chsone = new Chsone(obs , expect , 3 , 1); //chsone.caculate(); //prob = chsone.getPvalue(); prob = chsoneCalculate(obs,expect,3,1); if (prob > best_prob ) { best_prob = prob ; best_p = p ; } } p = best_p ; expect [1 ]= sum_obs * p * p ; expect [2 ]= sum_obs * 2.0 * p * (1.0 - p); expect [3 ]= sum_obs * (1.0 - p) * (1.0 - p); //Chsone chsone = new Chsone(obs , expect , 3 , 1); //chsone.caculate(); //this._p = chsone.getPvalue(); //return chsone.getPvalue(); return chsoneCalculate(obs,expect,3,1); }
|
private double hwCalculate(double obsAA, double obsAB, double obsBB){ double obs[]={0.0, obsAA, obsAB, obsBB}; double expect[]={0.0, 0.0, 0.0, 0.0}; double sum_obs; //double csq, df, sum_expect; double prob, p, start, end; double best_prob =-1.0; double best_p=0; sum_obs = obs [1 ]+ obs [2 ]+ obs [3 ]; for (p = 0.01 ; p <= .99 ; p += .01 ) { expect [1 ]= sum_obs * p * p ; expect [2 ]= sum_obs * 2.0 * p * (1.0 - p); expect [3 ]= sum_obs * (1.0 - p) * (1.0 - p); //Chsone chsone = new Chsone(obs , expect , 3 , 1); //chsone.caculate(); //prob = chsone.getPvalue(); prob = chsoneCalculate(obs,expect,3,1); if (prob > best_prob ) { best_prob = prob ; best_p = p ; } } start = (best_p - .025 > .001)? (best_p - .025): .001 ; end = (best_p + .025 < .999)? (best_p + .025): .999 ; for (p = start ; p <= end ; p += .001 ) { expect [1 ]= sum_obs * p * p ; expect [2 ]= sum_obs * 2.0 * p * (1.0 - p) ; expect [3 ]= sum_obs * (1.0 - p) * (1.0 - p) ; //Chsone chsone = new Chsone(obs , expect , 3 , 1); //chsone.caculate(); //prob = chsone.getPvalue(); prob = chsoneCalculate(obs,expect,3,1); if (prob > best_prob ) { best_prob = prob ; best_p = p ; } } p = best_p ; expect [1 ]= sum_obs * p * p ; expect [2 ]= sum_obs * 2.0 * p * (1.0 - p); expect [3 ]= sum_obs * (1.0 - p) * (1.0 - p); //Chsone chsone = new Chsone(obs , expect , 3 , 1); //chsone.caculate(); //this._p = chsone.getPvalue(); //return chsone.getPvalue(); return chsoneCalculate(obs,expect,3,1); }
| 1,111,613
|
public void runUnitTest(String name) throws Exception { // parse script InputStream in = new FileInputStream(name); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); assertTrue("Parsed a Script", script instanceof Script); StringWriter buffer = new StringWriter(); script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer)); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } // now lets parse the output Document document = DocumentHelper.parseText( text ); List failures = document.selectNodes( "/*/fail" ); for ( Iterator iter = failures.iterator(); iter.hasNext(); ) { Node node = (Node) iter.next(); fail( node.getStringValue() ); } }
|
public void runUnitTest(String name) throws Exception { // parse script InputStream in = new FileInputStream(name); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); assertTrue("Parsed a Script", script instanceof Script); StringWriter buffer = new StringWriter(); script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer)); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } // now lets parse the output Document document = DocumentHelper.parseText( text ); List failures = document.selectNodes( "/*/fail" ); for ( Iterator iter = failures.iterator(); iter.hasNext(); ) { Node node = (Node) iter.next(); fail( node.getStringValue() ); } }
| 1,111,614
|
public void runUnitTest(String name) throws Exception { // parse script InputStream in = new FileInputStream(name); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); assertTrue("Parsed a Script", script instanceof Script); StringWriter buffer = new StringWriter(); script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer)); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } // now lets parse the output Document document = DocumentHelper.parseText( text ); List failures = document.selectNodes( "/*/fail" ); for ( Iterator iter = failures.iterator(); iter.hasNext(); ) { Node node = (Node) iter.next(); fail( node.getStringValue() ); } }
|
public void runUnitTest(String name) throws Exception { // parse script InputStream in = new FileInputStream(name); XMLParser parser = new XMLParser(); Script script = parser.parse(in); script = script.compile(); assertTrue("Parsed a Script", script instanceof Script); StringWriter buffer = new StringWriter(); script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer)); String text = buffer.toString().trim(); if (log.isDebugEnabled()) { log.debug("Evaluated script as..."); log.debug(text); } // now lets parse the output List failures = document.selectNodes( "/*/fail" ); for ( Iterator iter = failures.iterator(); iter.hasNext(); ) { Node node = (Node) iter.next(); fail( node.getStringValue() ); } }
| 1,111,615
|
public IndividualDialog (HaploView h, String title) { super(h,title); JPanel contents = new JPanel(); JTable table; contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector people = h.theData.getPedFile().getAllIndividuals(); Vector excludedPeople = h.theData.getPedFile().getAxedPeople(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for (int i=0; i<excludedPeople.size(); i++){ Vector tmpVecB = new Vector(); Individual axedInd = (Individual)excludedPeople.get(i); tmpVecB.add(axedInd.getFamilyID()); tmpVecB.add(axedInd.getIndividualID()); tmpVecB.add(new Double(nf.format(axedInd.getGenoPC()*100))); data.add(tmpVecB); } for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(nf.format(currentInd.getGenoPC()*100))); data.add(tmpVec); } TableSorter sorter = new TableSorter(new BasicTableModel(colNames, data)); table = new JTable(sorter); sorter.setTableHeader(table.getTableHeader()); IndividualCellRenderer renderer = new IndividualCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Long"), renderer); table.setDefaultRenderer(Class.forName("java.lang.String"),renderer); }catch (Exception e){ } table.getColumnModel().getColumn(2).setPreferredWidth(30); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JPanel buttonPanel = new JPanel(); JButton exportButton = new JButton("Export to File"); exportButton.addActionListener(this); JButton okButton = new JButton("Close"); okButton.addActionListener(this); buttonPanel.add(exportButton); buttonPanel.add(okButton); contents.add(buttonPanel); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
|
public IndividualDialog (HaploView h, String title) { super(h,title); JPanel contents = new JPanel(); JTable table; contents.setLayout(new BoxLayout(contents,BoxLayout.Y_AXIS)); Vector people = h.theData.getPedFile().getAllIndividuals(); Vector excludedPeople = h.theData.getPedFile().getAxedPeople(); Vector colNames = new Vector(); colNames.add("FamilyID"); colNames.add("IndividualID"); colNames.add("Geno%"); Vector data = new Vector(); for (int i=0; i<excludedPeople.size(); i++){ Vector tmpVecB = new Vector(); Individual axedInd = (Individual)excludedPeople.get(i); tmpVecB.add(axedInd.getFamilyID()); tmpVecB.add(axedInd.getIndividualID()); tmpVecB.add(new Double(nf.format(axedInd.getGenoPC()*100))); data.add(tmpVecB); } for(int i=0;i<people.size();i++) { Vector tmpVec = new Vector(); Individual currentInd = (Individual)people.get(i); tmpVec.add(currentInd.getFamilyID()); tmpVec.add(currentInd.getIndividualID()); tmpVec.add(new Double(nf.format(currentInd.getGenoPC()*100))); data.add(tmpVec); } tableModel = new BasicTableModel(colNames,data); TableSorter sorter = new TableSorter(tableModel); table = new JTable(sorter); sorter.setTableHeader(table.getTableHeader()); IndividualCellRenderer renderer = new IndividualCellRenderer(); try{ table.setDefaultRenderer(Class.forName("java.lang.Double"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Integer"), renderer); table.setDefaultRenderer(Class.forName("java.lang.Long"), renderer); table.setDefaultRenderer(Class.forName("java.lang.String"),renderer); }catch (Exception e){ } table.getColumnModel().getColumn(2).setPreferredWidth(30); JScrollPane tableScroller = new JScrollPane(table); int tableHeight = (table.getRowHeight()+table.getRowMargin())*(table.getRowCount()+2); if (tableHeight > 300){ tableScroller.setPreferredSize(new Dimension(400, 300)); }else{ tableScroller.setPreferredSize(new Dimension(400, tableHeight)); } tableScroller.setBorder(BorderFactory.createEmptyBorder(2,5,2,5)); contents.add(tableScroller); JPanel buttonPanel = new JPanel(); JButton exportButton = new JButton("Export to File"); exportButton.addActionListener(this); JButton okButton = new JButton("Close"); okButton.addActionListener(this); buttonPanel.add(exportButton); buttonPanel.add(okButton); contents.add(buttonPanel); setContentPane(contents); this.setLocation(this.getParent().getX() + 100, this.getParent().getY() + 100); this.setModal(true); }
| 1,111,616
|
private static void dropTableNoFail(Connection con, String tableName) throws SQLException { Statement stmt = null; try { stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE "+tableName); } catch (SQLException e) { System.out.println("Ignoring SQLException. Assuming it means the table we tried to drop didn't exist."); e.printStackTrace(); } finally { if (stmt != null) stmt.close(); } }
|
private static void dropTableNoFail(Connection con, String tableName) throws SQLException { Statement stmt = null; try { stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE "+tableName); } catch (SQLException e) { System.out.println("Ignoring SQLException. Assume "+tableName+" didn't exist."); e.printStackTrace(); } finally { if (stmt != null) stmt.close(); } }
| 1,111,617
|
public static void oneTimeSetUp() throws Exception { System.out.println("TestSQLColumn.oneTimeSetUp()"); SQLDatabase mydb = new SQLDatabase(getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
|
public static void oneTimeSetUp() throws Exception { System.out.println("TestSQLColumn.oneTimeSetUp()"); SQLDatabase mydb = new SQLDatabase(getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
| 1,111,618
|
public static void oneTimeSetUp() throws Exception { System.out.println("TestSQLColumn.oneTimeSetUp()"); SQLDatabase mydb = new SQLDatabase(getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
|
public static void oneTimeSetUp() throws Exception { System.out.println("TestSQLColumn.oneTimeSetUp()"); SQLDatabase mydb = new SQLDatabase(getDataSource()); Connection con = mydb.getConnection(); Statement stmt = con.createStatement(); dropTableNoFail(con, "SQL_COLUMN_TEST_1PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_3PK"); dropTableNoFail(con, "SQL_COLUMN_TEST_0PK"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_1PK (\n" + " cow numeric(11) CONSTRAINT test1pk PRIMARY KEY,\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_3PK (\n" + " cow numeric(11) NOT NULL,\n" + " moo varchar(10) NOT NULL,\n" + " foo char(10) NOT NULL,\n" + " CONSTRAINT test3pk PRIMARY KEY (cow, moo, foo))"); stmt.executeUpdate("CREATE TABLE SQL_COLUMN_TEST_0PK (\n" + " cow numeric(11),\n" + " moo varchar(10),\n" + " foo char(10))"); stmt.close(); //mydb.disconnect(); FIXME: this should be uncommented when bug 1005 is fixed }
| 1,111,619
|
public void dbStructureChanged(SQLObjectEvent e) { throw new UnsupportedOperationException("not yet"); }
|
public void dbStructureChanged(SQLObjectEvent e) { if (!SwingUtilities.isEventDispatchThread()) return; try { ArchitectUtils.listenToHierarchy(this, e.getSQLSource()); TreeModelEvent tme = new TreeModelEvent(this, getPathToNode(e.getSQLSource())); fireTreeStructureChanged(tme); } catch (ArchitectException ex) { logger.error("Couldn't listen to hierarchy rooted at "+e.getSQLSource(), ex); } }
| 1,111,623
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { TreePath p = getPathForLocation(e.getX(), e.getY()); popup = refreshMenu(p); setSelectionPath(p); popup.show(e.getComponent(), e.getX(), e.getY()); } }
|
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { TreePath p = getPathForLocation(e.getX(), e.getY()); popup = refreshMenu(p); if (!isTargetDatabaseChild(p)) { setSelectionPath(p); } popup.show(e.getComponent(), e.getX(), e.getY()); } }
| 1,111,624
|
protected JPopupMenu refreshMenu(TreePath p) { logger.debug("refreshMenu is being called."); JPopupMenu newMenu = new JPopupMenu(); if (isTargetDatabaseNode(p)) { // two menu items: "Set Target Database" and "Connection Properties newMenu.add(popupDBCSMenu = new JMenu("Set Target Database")); if (ArchitectFrame.getMainInstance().getUserSettings().getConnections().size() == 0) { // disable if there's no connections in user settings yet (annoying, but less confusing) popupDBCSMenu.setEnabled(false); } else { // populate Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new setTargetDBCSAction(dbcs))); } } JMenuItem popupProperties = new JMenuItem(new DBCSPropertiesAction()); newMenu.add(popupProperties); } else if (p != null) { // clicked on DBCS item in DBTree JMenuItem popupProperties = new JMenuItem(new DBCSPropertiesAction()); newMenu.add(popupProperties); } else { // p == null, background click newMenu.add(popupDBCSMenu = new JMenu("Add Connection")); popupDBCSMenu.add(new JMenuItem(newDBCSAction)); popupDBCSMenu.addSeparator(); // populate Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } } // add in Show Listeners if debug is enabled if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; }
|
protected JPopupMenu refreshMenu(TreePath p) { logger.debug("refreshMenu is being called."); JPopupMenu newMenu = new JPopupMenu(); if (isTargetDatabaseNode(p)) { // two menu items: "Set Target Database" and "Connection Properties newMenu.add(popupDBCSMenu = new JMenu("Set Target Database")); if (ArchitectFrame.getMainInstance().getUserSettings().getConnections().size() == 0) { // disable if there's no connections in user settings yet (annoying, but less confusing) popupDBCSMenu.setEnabled(false); } else { // populate Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new setTargetDBCSAction(dbcs))); } } JMenuItem popupProperties = new JMenuItem(new DBCSPropertiesAction()); newMenu.add(popupProperties); } else if (isTargetDatabaseChild(p)) { ArchitectFrame af = ArchitectFrame.getMainInstance(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.insertColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } newMenu.addSeparator(); mi = new JMenuItem(); mi.setAction(af.editTableAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.editRelationshipAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLRelationship.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLRelationship.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } } else if (p != null) { // clicked on DBCS item in DBTree JMenuItem popupProperties = new JMenuItem(new DBCSPropertiesAction()); newMenu.add(popupProperties); } else if (isTargetDatabaseChild(p)) { ArchitectFrame af = ArchitectFrame.getMainInstance(); JMenuItem mi; mi = new JMenuItem(); mi.setAction(af.editColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.insertColumnAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } newMenu.addSeparator(); mi = new JMenuItem(); mi.setAction(af.editTableAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.editRelationshipAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLRelationship.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } mi = new JMenuItem(); mi.setAction(af.deleteSelectedAction); mi.setActionCommand(ArchitectSwingConstants.ACTION_COMMAND_SRC_DBTREE); newMenu.add(mi); if(p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLTable.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLColumn.class || p.getLastPathComponent().getClass() == ca.sqlpower.architect.SQLRelationship.class) { mi.setEnabled(true); } else { mi.setEnabled(false); } } else { // p == null, background click newMenu.add(popupDBCSMenu = new JMenu("Add Connection")); popupDBCSMenu.add(new JMenuItem(newDBCSAction)); popupDBCSMenu.addSeparator(); // populate Iterator it = ArchitectFrame.getMainInstance().getUserSettings().getConnections().iterator(); while(it.hasNext()) { DBConnectionSpec dbcs = (DBConnectionSpec) it.next(); popupDBCSMenu.add(new JMenuItem(new AddDBCSAction(dbcs))); } } // add in Show Listeners if debug is enabled if (logger.isDebugEnabled()) { newMenu.addSeparator(); JMenuItem showListeners = new JMenuItem("Show Listeners"); showListeners.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SQLObject so = (SQLObject) getLastSelectedPathComponent(); if (so != null) { JOptionPane.showMessageDialog(DBTree.this, new JScrollPane(new JList(new java.util.Vector(so.getSQLObjectListeners())))); } } }); newMenu.add(showListeners); } return newMenu; }
| 1,111,625
|
void saveHapsToText(){ fc.setSelctedFile(null); try{ fc.setSelectedFile(null); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { new TextMethods().saveHapsToText(finishedHaplos, fc.getSelectedFile()); } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
|
void saveHapsToText(){ fc.setSelectedFile(null); try{ fc.setSelectedFile(null); int returnVal = fc.showSaveDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { new TextMethods().saveHapsToText(finishedHaplos, fc.getSelectedFile()); } }catch (IOException ioexec){ JOptionPane.showMessageDialog(this, ioexec.getMessage(), "File Error", JOptionPane.ERROR_MESSAGE); } }
| 1,111,627
|
public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "New Connection", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } }
|
public void actionPerformed(ActionEvent e) { TreePath p = getSelectionPath(); if (p == null) { return; } Object [] pathArray = p.getPath(); int ii = 0; SQLDatabase sd = null; while (ii < pathArray.length && sd == null) { if (pathArray[ii] instanceof SQLDatabase) { sd = (SQLDatabase) pathArray[ii]; } ii++; } if (sd != null) { final DBCSPanel dbcsPanel = new DBCSPanel(); ArchitectDataSource dbcs = sd.getDataSource(); dbcsPanel.setDbcs(new ArchitectDataSource()); DBCS_OkAction okButton = new DBCS_OkAction(dbcsPanel,true); Action cancelAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { dbcsPanel.discardChanges(); } }; JDialog d = ArchitectPanelBuilder.createArchitectPanelDialog( dbcsPanel,ArchitectFrame.getMainInstance(), "Connection Properties", ArchitectPanelBuilder.OK_BUTTON_LABEL, okButton, cancelAction); okButton.setConnectionDialog(d); d.pack(); d.setLocationRelativeTo(ArchitectFrame.getMainInstance()); d.setVisible(true); logger.debug("Setting existing DBCS on panel: "+dbcs); edittingDB = sd; dbcsPanel.setDbcs(dbcs); } }
| 1,111,628
|
protected void setup() { GenericDDLGenerator ddlg = project.getDDLGenerator(); setLayout(new FormLayout()); Vector dbTypeList = new Vector(); dbTypeList.add(ASUtils.lvb("Generic JDBC", GenericDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("DB2", DB2DDLGenerator.class)); dbTypeList.add(ASUtils.lvb("Oracle 8i/9i", OracleDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("SQLServer 2000", SQLServerDDLGenerator.class)); add(new JLabel("Generate DDL for Database Type:")); add(dbType = new JComboBox(dbTypeList)); if (ddlg.getClass() == GenericDDLGenerator.class) { dbType.setSelectedIndex(0); } else if (ddlg.getClass() == DB2DDLGenerator.class) { dbType.setSelectedIndex(1); } else if (ddlg.getClass() == OracleDDLGenerator.class) { dbType.setSelectedIndex(2); } else if (ddlg.getClass() == SQLServerDDLGenerator.class) { dbType.setSelectedIndex(3); } else { logger.error("Unknown DDL generator class "+ddlg.getClass()); dbType.addItem(ASUtils.lvb("Unknwon Generator", ddlg.getClass())); } }
|
protected void setup() { GenericDDLGenerator ddlg = project.getDDLGenerator(); setLayout(new FormLayout()); Vector dbTypeList = new Vector(); dbTypeList.add(ASUtils.lvb("Generic JDBC", GenericDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("DB2", DB2DDLGenerator.class)); dbTypeList.add(ASUtils.lvb("Oracle 8i/9i", OracleDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("SQLServer 2000", SQLServerDDLGenerator.class)); add(new JLabel("Generate DDL for Database Type:")); add(dbType = new JComboBox(dbTypeList)); if (ddlg.getClass() == GenericDDLGenerator.class) { dbType.setSelectedIndex(0); } else if (ddlg.getClass() == DB2DDLGenerator.class) { dbType.setSelectedIndex(1); } else if (ddlg.getClass() == OracleDDLGenerator.class) { dbType.setSelectedIndex(2); } else if (ddlg.getClass() == SQLServerDDLGenerator.class) { dbType.setSelectedIndex(4); } else { logger.error("Unknown DDL generator class "+ddlg.getClass()); dbType.addItem(ASUtils.lvb("Unknwon Generator", ddlg.getClass())); } }
| 1,111,630
|
protected void setup() { GenericDDLGenerator ddlg = project.getDDLGenerator(); setLayout(new FormLayout()); Vector dbTypeList = new Vector(); dbTypeList.add(ASUtils.lvb("Generic JDBC", GenericDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("DB2", DB2DDLGenerator.class)); dbTypeList.add(ASUtils.lvb("Oracle 8i/9i", OracleDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("SQLServer 2000", SQLServerDDLGenerator.class)); add(new JLabel("Generate DDL for Database Type:")); add(dbType = new JComboBox(dbTypeList)); if (ddlg.getClass() == GenericDDLGenerator.class) { dbType.setSelectedIndex(0); } else if (ddlg.getClass() == DB2DDLGenerator.class) { dbType.setSelectedIndex(1); } else if (ddlg.getClass() == OracleDDLGenerator.class) { dbType.setSelectedIndex(2); } else if (ddlg.getClass() == SQLServerDDLGenerator.class) { dbType.setSelectedIndex(3); } else { logger.error("Unknown DDL generator class "+ddlg.getClass()); dbType.addItem(ASUtils.lvb("Unknwon Generator", ddlg.getClass())); } }
|
protected void setup() { GenericDDLGenerator ddlg = project.getDDLGenerator(); setLayout(new FormLayout()); Vector dbTypeList = new Vector(); dbTypeList.add(ASUtils.lvb("Generic JDBC", GenericDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("DB2", DB2DDLGenerator.class)); dbTypeList.add(ASUtils.lvb("Oracle 8i/9i", OracleDDLGenerator.class)); dbTypeList.add(ASUtils.lvb("SQLServer 2000", SQLServerDDLGenerator.class)); add(new JLabel("Generate DDL for Database Type:")); add(dbType = new JComboBox(dbTypeList)); if (ddlg.getClass() == GenericDDLGenerator.class) { dbType.setSelectedIndex(0); } else if (ddlg.getClass() == DB2DDLGenerator.class) { dbType.setSelectedIndex(1); } else if (ddlg.getClass() == OracleDDLGenerator.class) { dbType.setSelectedIndex(2); } else if (ddlg.getClass() == SQLServerDDLGenerator.class) { dbType.setSelectedIndex(3); } else { logger.error("Unknown DDL generator class "+ddlg.getClass()); dbType.addItem(ASUtils.lvb("Unknown Generator", ddlg.getClass())); } }
| 1,111,631
|
public Object createDataType(String name) { Object dataType = null; Class type = (Class) getAntProject().getDataTypeDefinitions().get(name); if ( type != null ) { Constructor ctor = null; boolean noArg = false; // DataType can have a "no arg" constructor or take a single // Project argument. try { ctor = type.getConstructor(new Class[0]); noArg = true; } catch (NoSuchMethodException nse) { try { ctor = type.getConstructor(new Class[] { Project.class }); noArg = false; } catch (NoSuchMethodException nsme) { log.info("datatype '" + name + "' didn't have a constructor with an Ant Project", nsme); } } if (noArg) { dataType = createDataType(ctor, new Object[0], name, "no-arg constructor"); } else { dataType = createDataType(ctor, new Object[] { getAntProject() }, name, "an Ant project"); } if (dataType != null) { ((DataType)dataType).setProject( getAntProject() ); } } return dataType; }
|
public Object createDataType(String name) { Object dataType = null; Class type = (Class) getAntProject().getDataTypeDefinitions().get(name); if ( type != null ) { Constructor ctor = null; boolean noArg = false; // DataType can have a "no arg" constructor or take a single // Project argument. try { ctor = type.getConstructor(new Class[0]); noArg = true; } catch (NoSuchMethodException nse) { try { ctor = type.getConstructor(new Class[] { Project.class }); noArg = false; } catch (NoSuchMethodException nsme) { log.info("datatype '" + name + "' didn't have a constructor with an Ant Project", nsme); } } if (noArg) { dataType = createDataType(ctor, new Object[0], name, "no-arg constructor"); } else { dataType = createDataType(ctor, new Object[] { getAntProject() }, name, "an Ant project"); } if (dataType != null && dataType instanceof DataType) { ((DataType)dataType).setProject( getAntProject() ); } } return dataType; }
| 1,111,632
|
public Object createNestedObject(Object object, String name) { Object dataType = null; if ( object != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( ih != null ) { try { dataType = ih.createElement( getAntProject(), object, name.toLowerCase() ); } catch (BuildException be) { if (object instanceof Tag) { if (log.isDebugEnabled()) { log.debug("Failed attempt to create an ant datatype for a jelly tag", be); } } else { log.error(be); } } } } if ( dataType == null ) { dataType = createDataType( name ); } return dataType; }
|
public Object createNestedObject(Object object, String name) { Object dataType = null; if ( object != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( ih != null && ! (object instanceof AntTag)) { try { dataType = ih.createElement( getAntProject(), object, name.toLowerCase() ); } catch (BuildException be) { if (object instanceof Tag) { if (log.isDebugEnabled()) { log.debug("Failed attempt to create an ant datatype for a jelly tag", be); } } else { log.error(be); } } } } if ( dataType == null ) { dataType = createDataType( name ); } return dataType; }
| 1,111,633
|
public void doTag(XMLOutput output) throws JellyTagException { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> Object nested = null; if (parentObject != null && !( parentTask instanceof TaskContainer) ) { nested = createNestedObject( parentObject, tagName ); } if (nested == null) { task = createTask( tagName ); if (task != null) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; try { method.invoke(this.task, args); } catch (IllegalAccessException e) { throw new JellyTagException(e); } catch (InvocationTargetException e) { throw new JellyTagException(e); } } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? // according to org.apache.tools.ant.Main, redirect stdout and stderr PrintStream initialOut = System.out; PrintStream initialErr = System.err; PrintStream newOut = new PrintStream(new DemuxOutputStream(project, false)); PrintStream newErr = new PrintStream(new DemuxOutputStream(project, true)); try { System.setOut(newOut); System.setErr(newErr); task.perform(); } finally { System.setOut(initialOut); System.setErr(initialErr); } } } if (task == null) { if (nested == null) { if ( log.isDebugEnabled() ) { log.debug( "Trying to create a data type for tag: " + tagName ); } nested = createDataType( tagName ); } else { if ( log.isDebugEnabled() ) { log.debug( "Created nested property tag: " + tagName ); } } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } // TODO: work out why we always set the name attribute. // See JELLY-105.// try{// PropertyUtils.setProperty( nested, "name", tagName );// }// catch (Exception e) {// log.warn( "Caught exception setting nested name: " + tagName, e );// } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName.toLowerCase() ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { log.warn("Could not convert tag: " + tagName + " into an Ant task, data type or property"); // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
|
public void doTag(XMLOutput output) throws JellyTagException { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> Object nested = null; if (parentObject != null && !( parentTask instanceof TaskContainer) ) { nested = createNestedObject( parentObject, tagName ); } if (nested == null) { task = createTask( tagName ); if (task != null) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; try { method.invoke(this.task, args); } catch (IllegalAccessException e) { throw new JellyTagException(e); } catch (InvocationTargetException e) { throw new JellyTagException(e); } } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? // according to org.apache.tools.ant.Main, redirect stdout and stderr PrintStream initialOut = System.out; PrintStream initialErr = System.err; PrintStream newOut = new PrintStream(new DemuxOutputStream(project, false)); PrintStream newErr = new PrintStream(new DemuxOutputStream(project, true)); try { System.setOut(newOut); System.setErr(newErr); task.perform(); } finally { System.setOut(initialOut); System.setErr(initialErr); } } } if (task == null) { if (nested == null) { if ( log.isDebugEnabled() ) { log.debug( "Trying to create a data type for tag: " + tagName ); } nested = createDataType( tagName ); } else { if ( log.isDebugEnabled() ) { log.debug( "Created nested property tag: " + tagName ); } } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } // TODO: work out why we always set the name attribute. // See JELLY-105.// try{// PropertyUtils.setProperty( nested, "name", tagName );// }// catch (Exception e) {// log.warn( "Caught exception setting nested name: " + tagName, e );// } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + safeToString(parentObject) + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName.toLowerCase() ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { log.warn("Could not convert tag: " + tagName + " into an Ant task, data type or property"); // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
| 1,111,634
|
public void doTag(XMLOutput output) throws JellyTagException { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> Object nested = null; if (parentObject != null && !( parentTask instanceof TaskContainer) ) { nested = createNestedObject( parentObject, tagName ); } if (nested == null) { task = createTask( tagName ); if (task != null) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; try { method.invoke(this.task, args); } catch (IllegalAccessException e) { throw new JellyTagException(e); } catch (InvocationTargetException e) { throw new JellyTagException(e); } } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? // according to org.apache.tools.ant.Main, redirect stdout and stderr PrintStream initialOut = System.out; PrintStream initialErr = System.err; PrintStream newOut = new PrintStream(new DemuxOutputStream(project, false)); PrintStream newErr = new PrintStream(new DemuxOutputStream(project, true)); try { System.setOut(newOut); System.setErr(newErr); task.perform(); } finally { System.setOut(initialOut); System.setErr(initialErr); } } } if (task == null) { if (nested == null) { if ( log.isDebugEnabled() ) { log.debug( "Trying to create a data type for tag: " + tagName ); } nested = createDataType( tagName ); } else { if ( log.isDebugEnabled() ) { log.debug( "Created nested property tag: " + tagName ); } } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } // TODO: work out why we always set the name attribute. // See JELLY-105.// try{// PropertyUtils.setProperty( nested, "name", tagName );// }// catch (Exception e) {// log.warn( "Caught exception setting nested name: " + tagName, e );// } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName.toLowerCase() ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + parentObject); } } } else { log.warn("Could not convert tag: " + tagName + " into an Ant task, data type or property"); // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
|
public void doTag(XMLOutput output) throws JellyTagException { Project project = getAntProject(); String tagName = getTagName(); Object parentObject = findBeanAncestor(); Object parentTask = findParentTaskObject(); // lets assume that Task instances are not nested inside other Task instances // for example <manifest> inside a <jar> should be a nested object, where as // if the parent is not a Task the <manifest> should create a ManifestTask // // also its possible to have a root Ant tag which isn't a task, such as when // defining <fileset id="...">...</fileset> Object nested = null; if (parentObject != null && !( parentTask instanceof TaskContainer) ) { nested = createNestedObject( parentObject, tagName ); } if (nested == null) { task = createTask( tagName ); if (task != null) { if ( log.isDebugEnabled() ) { log.debug( "Creating an ant Task for name: " + tagName ); } // the following algorithm follows the lifetime of a tag // http://jakarta.apache.org/ant/manual/develop.html#writingowntask // kindly recommended by Stefan Bodewig // create and set its project reference if ( task instanceof TaskAdapter ) { setObject( ((TaskAdapter)task).getProxy() ); } else { setObject( task ); } // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, task ); } // ### we might want to spoof a Target setting here // now lets initialize task.init(); // now lets invoke the body to call all the createXXX() or addXXX() methods String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets set the addText() of the body content, if its applicaable Method method = MethodUtils.getAccessibleMethod( task.getClass(), "addText", addTaskParamTypes ); if (method != null) { Object[] args = { body }; try { method.invoke(this.task, args); } catch (IllegalAccessException e) { throw new JellyTagException(e); } catch (InvocationTargetException e) { throw new JellyTagException(e); } } // now lets set all the attributes of the child elements // XXXX: to do! // now we're ready to invoke the task // XXX: should we call execute() or perform()? // according to org.apache.tools.ant.Main, redirect stdout and stderr PrintStream initialOut = System.out; PrintStream initialErr = System.err; PrintStream newOut = new PrintStream(new DemuxOutputStream(project, false)); PrintStream newErr = new PrintStream(new DemuxOutputStream(project, true)); try { System.setOut(newOut); System.setErr(newErr); task.perform(); } finally { System.setOut(initialOut); System.setErr(initialErr); } } } if (task == null) { if (nested == null) { if ( log.isDebugEnabled() ) { log.debug( "Trying to create a data type for tag: " + tagName ); } nested = createDataType( tagName ); } else { if ( log.isDebugEnabled() ) { log.debug( "Created nested property tag: " + tagName ); } } if ( nested != null ) { setObject( nested ); // set the task ID if one is given Object id = getAttributes().remove( "id" ); if ( id != null ) { project.addReference( (String) id, nested ); } // TODO: work out why we always set the name attribute. // See JELLY-105.// try{// PropertyUtils.setProperty( nested, "name", tagName );// }// catch (Exception e) {// log.warn( "Caught exception setting nested name: " + tagName, e );// } // now lets invoke the body String body = getBodyText(); // now lets set any attributes of this tag... setBeanProperties(); // now lets add it to its parent if ( parentObject != null ) { IntrospectionHelper ih = IntrospectionHelper.getHelper( parentObject.getClass() ); try { if (log.isDebugEnabled()) { log.debug("About to set the: " + tagName + " property on: " + parentObject + " to value: " + nested + " with type: " + nested.getClass() ); } ih.storeElement( project, parentObject, nested, tagName.toLowerCase() ); } catch (Exception e) { log.warn( "Caught exception setting nested: " + tagName, e ); } // now try to set the property for good measure // as the storeElement() method does not // seem to call any setter methods of non-String types try { BeanUtils.setProperty( parentObject, tagName, nested ); } catch (Exception e) { log.debug("Caught exception trying to set property: " + tagName + " on: " + safeToString(parentObject)); } } } else { log.warn("Could not convert tag: " + tagName + " into an Ant task, data type or property"); // lets treat this tag as static XML... StaticTag tag = new StaticTag("", tagName, tagName); tag.setParent( getParent() ); tag.setBody( getBody() ); tag.setContext(context); for (Iterator iter = getAttributes().entrySet().iterator(); iter.hasNext();) { Map.Entry entry = (Map.Entry) iter.next(); String name = (String) entry.getKey(); Object value = entry.getValue(); tag.setAttribute(name, value); } tag.doTag(output); } } }
| 1,111,635
|
public void setBeanProperty(Object object, String name, Object value) throws JellyTagException { if ( log.isDebugEnabled() ) { log.debug( "Setting bean property on: "+ object + " name: " + name + " value: " + value ); } IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( value instanceof String ) { try { ih.setAttribute( getAntProject(), object, name.toLowerCase(), (String) value ); return; } catch (Exception e) { // ignore: not a valid property } } try { ih.storeElement( getAntProject(), object, value, name ); } catch (Exception e) { try { // let any exceptions bubble up from here BeanUtils.setProperty( object, name, value ); } catch (IllegalAccessException ex) { throw new JellyTagException(ex); } catch (InvocationTargetException ex) { throw new JellyTagException(ex); } } }
|
public void setBeanProperty(Object object, String name, Object value) throws JellyTagException { if ( log.isDebugEnabled() ) { log.debug( "Setting bean property on: "+ safeToString(object )+ " name: " + name + " value: " + safeToString(value)); } IntrospectionHelper ih = IntrospectionHelper.getHelper( object.getClass() ); if ( value instanceof String ) { try { ih.setAttribute( getAntProject(), object, name.toLowerCase(), (String) value ); return; } catch (Exception e) { // ignore: not a valid property } } try { ih.storeElement( getAntProject(), object, value, name ); } catch (Exception e) { try { // let any exceptions bubble up from here BeanUtils.setProperty( object, name, value ); } catch (IllegalAccessException ex) { throw new JellyTagException(ex); } catch (InvocationTargetException ex) { throw new JellyTagException(ex); } } }
| 1,111,636
|
private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =null; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = null; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,""); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } }
|
private void doBatch() { Vector files; File batchFile; File dataFile; String line; StringTokenizer tok; String infoMaybe =null; files = new Vector(); if(batchFileName == null) { return; } batchFile = new File(this.batchFileName); if(!batchFile.exists()) { System.out.println("batch file " + batchFileName + " does not exist"); System.exit(1); } if (!quietMode) System.out.println("Processing batch input file: " + batchFile); try { BufferedReader br = new BufferedReader(new FileReader(batchFile)); while( (line = br.readLine()) != null ) { files.add(line); } br.close(); for(int i = 0;i<files.size();i++){ line = (String)files.get(i); tok = new StringTokenizer(line); infoMaybe = null; if(tok.hasMoreTokens()){ dataFile = new File(tok.nextToken()); if(tok.hasMoreTokens()){ infoMaybe = tok.nextToken(); } if(dataFile.exists()) { String name = dataFile.getName(); if( name.substring(name.length()-4,name.length()).equalsIgnoreCase(".ped") ) { processFile(name,PED_FILE,infoMaybe); } else if(name.substring(name.length()-5,name.length()).equalsIgnoreCase(".haps")) { processFile(name,HAPS_FILE,infoMaybe); } else if(name.substring(name.length()-4,name.length()).equalsIgnoreCase(".hmp")){ processFile(name,HMP_FILE,null); } else{ if (!quietMode){ System.out.println("Filenames in batch file must end in .ped, .haps or .hmp\n" + name + " is not properly formatted."); } } } else { if(!quietMode){ System.out.println("file " + dataFile.getName() + " listed in the batch file could not be found"); } } } } } catch(FileNotFoundException e){ System.out.println("the following error has occured:\n" + e.toString()); } catch(IOException e){ System.out.println("the following error has occured:\n" + e.toString()); } }
| 1,111,637
|
protected void updateModel() { logger.debug("Updating model"); try { SQLColumn col = model.getColumn(index); col.setName(colName.getText()); col.setType(((SQLType) colType.getSelectedItem()).type); col.setScale(((Integer) colScale.getValue()).intValue()); col.setPrecision(((Integer) colPrec.getValue()).intValue()); col.setNullable(colNullable.isSelected() ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls); col.setRemarks(colRemarks.getText()); if (!(col.getDefaultValue() == null && colDefaultValue.getText().equals(""))) { col.setDefaultValue(colDefaultValue.getText()); } // Autoincrement has to go before the primary key or // this column will never allow nulls col.setAutoIncrement(colAutoInc.isSelected()); col.setPrimaryKeySeq(colInPK.isSelected() ? new Integer(model.getPkSize()) : null); // update selected index in case the column moved (add/remove PK) int index = model.getColumns().indexOf(col); selectColumn(index); } catch (ArchitectException ex) { JOptionPane.showMessageDialog(this, "Couldn't update column information"); logger.error("Couldn't update model!", ex); } }
|
protected void updateModel() { logger.debug("Updating model"); try { SQLColumn col = model.getColumn(index); col.setName(colName.getText()); col.setType(((SQLType) colType.getSelectedItem()).type); col.setScale(((Integer) colScale.getValue()).intValue()); col.setPrecision(((Integer) colPrec.getValue()).intValue()); col.setNullable(colNullable.isSelected() ? DatabaseMetaData.columnNullable : DatabaseMetaData.columnNoNulls); col.setRemarks(colRemarks.getText()); if (!(col.getDefaultValue() == null && colDefaultValue.getText().equals(""))) { col.setDefaultValue(colDefaultValue.getText()); } // Autoincrement has to go before the primary key or // this column will never allow nulls col.setAutoIncrement(colAutoInc.isSelected()); if (col.getPrimaryKeySeq() == null) { col.setPrimaryKeySeq(colInPK.isSelected() ? new Integer(model.getPkSize()) : null); } else { col.setPrimaryKeySeq(colInPK.isSelected() ? new Integer(col.getPrimaryKeySeq()) : null); } // update selected index in case the column moved (add/remove PK) int index = model.getColumns().indexOf(col); selectColumn(index); } catch (ArchitectException ex) { JOptionPane.showMessageDialog(this, "Couldn't update column information"); logger.error("Couldn't update model!", ex); } }
| 1,111,638
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
|
public void adjustDisplay(){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
| 1,111,639
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > Options.getHaplotypeDisplayThreshold()){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
| 1,111,640
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + Options.getHaplotypeDisplayThreshold(), "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
| 1,111,641
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } displayThresh = dt; filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
|
public void adjustDisplay(int dt){ //this is called when the controller wants to change the haps //displayed, instead of directly repainting so that none of this math //is done when the screen repaints for other reasons (resizing, focus change, etc) //first filter haps on displaythresh Haplotype[][] filts; filts = new Haplotype[orderedHaplos.length][]; int numhaps = 0; int printable = 0; for (int i = 0; i < orderedHaplos.length; i++){ Vector tempVector = new Vector(); for (int j = 0; j < orderedHaplos[i].length; j++){ if (orderedHaplos[i][j].getPercentage()*100 > dt){ tempVector.add(orderedHaplos[i][j]); numhaps++; } } if (numhaps > 1){ printable++; numhaps=0; } filts[i] = new Haplotype[tempVector.size()]; tempVector.copyInto(filts[i]); } // if user sets display thresh higher than most common hap in any given block if (!(printable == filts.length)){ JOptionPane.showMessageDialog(this.getParent(), "Error: At least one block has too few haplotypes of frequency > " + dt, "Error", JOptionPane.ERROR_MESSAGE); return; } filteredHaplos = filts; //then re-tag try{ filteredHaplos = theData.generateCrossovers(filteredHaplos); }catch (HaploViewException e){ JOptionPane.showMessageDialog(this.getParent(), e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } multidprimeArray = theData.getMultiDprime(); //if the haps pane exists, we want to make sure the vert scroll bar appears if necessary if (this.getParent() != null){ if (this.getPreferredSize().height > this.getParent().getHeight()){ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); }else{ ((JScrollPane)this.getParent().getParent()).setVerticalScrollBarPolicy( JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); } } repaint(); }
| 1,111,642
|
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks, 0); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(displayThresh); }
|
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks, 0,false); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(displayThresh); }
| 1,111,643
|
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks, 0); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(displayThresh); }
|
public void getHaps() throws HaploViewException{ if (theData.blocks == null) {return;} Haplotype[][] haplos = theData.generateHaplotypes(theData.blocks, 0); orderedHaplos = new Haplotype[haplos.length][]; for (int i = 0; i < haplos.length; i++) { Vector orderedHaps = new Vector(); //step through each haplotype in this block for (int hapCount = 0; hapCount < haplos[i].length; hapCount++) { if (orderedHaps.size() == 0) { orderedHaps.add(haplos[i][hapCount]); } else { for (int j = 0; j < orderedHaps.size(); j++) { if (((Haplotype)(orderedHaps.elementAt(j))).getPercentage() < haplos[i][hapCount].getPercentage()) { orderedHaps.add(j, haplos[i][hapCount]); break; } if ((j+1) == orderedHaps.size()) { orderedHaps.add(haplos[i][hapCount]); break; } } } } orderedHaplos[i] = new Haplotype[orderedHaps.size()]; orderedHaps.copyInto(orderedHaplos[i]); } adjustDisplay(); }
| 1,111,644
|
public void removeDataSource(ArchitectDataSource dbcs) { int where = fileSections.indexOf(dbcs); if (where < 0) throw new IllegalArgumentException("dbcs not in list"); fileSections.remove(dbcs); fireRemoveEvent(where, dbcs); }
|
public void removeDataSource(ArchitectDataSource dbcs) { int where = fileSections.indexOf(dbcs); if (where < 0) throw new IllegalArgumentException("dbcs not in list"); fileSections.remove(dbcs); fireRemoveEvent(where, dbcs); }
| 1,111,645
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.