* half the available width or height (whichever is less); increase this
* factor to zoom in, decrease it to zoom out
*/
- float scaleFactor;
+ private float scaleFactor;
int npoint;
/*
* x, y, z axis end points (PCA dimension values)
*/
- Point[] axisEndPoints;
+ private Point[] axisEndPoints;
// fields for 'select rectangle' (JAL-1124)
// int rectx1;
AlignmentPanel ap;
- boolean showLabels;
+ private boolean showLabels;
- Color bgColour;
+ private Color bgColour;
- boolean applyToAllViews;
+ private boolean applyToAllViews;
/**
* Constructor
{
this.av = panel.av;
this.ap = panel;
- axisEndPoints = new Point[DIMS];
- showLabels = false;
- applyToAllViews = false;
- bgColour = Color.BLACK;
+ setAxisEndPoints(new Point[DIMS]);
+ setShowLabels(false);
+ setApplyToAllViews(false);
+ setBgColour(Color.BLACK);
resetAxes();
ToolTipManager.sharedInstance().registerComponent(this);
*/
public void showLabels(boolean show)
{
- showLabels = show;
+ setShowLabels(show);
repaint();
}
findWidths();
- scaleFactor = 1f;
+ setScaleFactor(1f);
}
/**
*/
protected void resetAxes()
{
- axisEndPoints[0] = new Point(1f, 0f, 0f);
- axisEndPoints[1] = new Point(0f, 1f, 0f);
- axisEndPoints[2] = new Point(0f, 0f, 1f);
+ getAxisEndPoints()[0] = new Point(1f, 0f, 0f);
+ getAxisEndPoints()[1] = new Point(0f, 1f, 0f);
+ getAxisEndPoints()[2] = new Point(0f, 0f, 1f);
}
/**
ig = img.getGraphics();
}
- drawBackground(ig, bgColour);
+ drawBackground(ig);
drawScene(ig);
if (drawAxes)
float maxWidth = Math.max(Math.abs(seqMax[0] - seqMin[0]),
Math.abs(seqMax[1] - seqMin[1]));
int pix = Math.min(getWidth(), getHeight());
- float scaleBy = pix * scaleFactor / (2f * maxWidth);
+ float scaleBy = pix * getScaleFactor() / (2f * maxWidth);
for (int i = 0; i < DIMS; i++)
{
g.drawLine(midX, midY,
- midX + (int) (axisEndPoints[i].x * scaleBy * seqMax[0]),
- midY + (int) (axisEndPoints[i].y * scaleBy * seqMax[1]));
+ midX + (int) (getAxisEndPoints()[i].x * scaleBy * seqMax[0]),
+ midY + (int) (getAxisEndPoints()[i].y * scaleBy * seqMax[1]));
}
}
/**
- * Fills the background with the specified colour
+ * Fills the background with the currently configured background colour
*
* @param g
- * @param col
*/
- public void drawBackground(Graphics g, Color col)
+ public void drawBackground(Graphics g)
{
- g.setColor(col);
+ g.setColor(getBgColour());
g.fillRect(0, 0, prefSize.width, prefSize.height);
}
float xWidth = Math.abs(seqMax[0] - seqMin[0]);
float yWidth = Math.abs(seqMax[1] - seqMin[1]);
float maxWidth = Math.max(xWidth, yWidth);
- float scaleBy = pix * scaleFactor / (2f * maxWidth);
+ float scaleBy = pix * getScaleFactor() / (2f * maxWidth);
float[] centre = getCentre();
int y = (int) ((sp.coord.y - centre[1]) * scaleBy) + halfheight;
g.fillRect(x - 3, y - 3, 6, 6);
- if (showLabels)
+ if (isShowLabels())
{
g.setColor(Color.red);
g.drawString(sp.getSequence().getName(), x - 3, y - 4);
}
}
- if (showLabels)
+ if (isShowLabels())
{
g.setColor(AXIS_COLOUR);
int midX = getWidth() / 2;
int midY = getHeight() / 2;
Iterator<String> axes = AXES.iterator();
- for (Point p : axisEndPoints)
+ for (Point p : getAxisEndPoints())
{
int x = midX + (int) (p.x * scaleBy * seqMax[0]);
int y = midY + (int) (p.y * scaleBy * seqMax[1]);
{
if (factor > 0f)
{
- scaleFactor *= factor;
+ setScaleFactor(getScaleFactor() * factor);
}
}
int yDelta = yPos - mouseY;
// Check if this is a rectangle drawing drag
- if ((evt.getModifiers() & InputEvent.BUTTON2_MASK) != 0)
+ if ((evt.getModifiersEx() & InputEvent.BUTTON2_DOWN_MASK) != 0)
{
// rectx2 = evt.getX();
// recty2 = evt.getY();
*/
for (int i = 0; i < DIMS; i++)
{
- axisEndPoints[i] = rotmat.vectorMultiply(axisEndPoints[i]);
+ getAxisEndPoints()[i] = rotmat.vectorMultiply(getAxisEndPoints()[i]);
}
}
for (int i = 0; i < npoint; i++)
{
SequencePoint sp = sequencePoints.get(i);
- int tmp1 = (int) (((sp.coord.x - centre[0]) * scaleFactor)
+ int tmp1 = (int) (((sp.coord.x - centre[0]) * getScaleFactor())
+ (getWidth() / 2.0));
- int tmp2 = (int) (((sp.coord.y - centre[1]) * scaleFactor)
+ int tmp2 = (int) (((sp.coord.y - centre[1]) * getScaleFactor())
+ (getHeight() / 2.0));
if ((tmp1 > x1) && (tmp1 < x2) && (tmp2 > y1) && (tmp2 < y2))
float xWidth = Math.abs(seqMax[0] - seqMin[0]);
float yWidth = Math.abs(seqMax[1] - seqMin[1]);
float maxWidth = Math.max(xWidth, yWidth);
- float scaleBy = pix * scaleFactor / (2f * maxWidth);
+ float scaleBy = pix * getScaleFactor() / (2f * maxWidth);
float[] centre = getCentre();
*/
AlignmentPanel[] getAssociatedPanels()
{
- if (applyToAllViews)
+ if (isApplyToAllViews())
{
return PaintRefresher.getAssociatedPanels(av.getSequenceSetId());
}
public Color getBackgroundColour()
{
- return bgColour;
+ return getBgColour();
}
/**
seqMin = min;
seqMax = max;
}
+
+ public float getScaleFactor()
+ {
+ return scaleFactor;
+ }
+
+ public void setScaleFactor(float scaleFactor)
+ {
+ this.scaleFactor = scaleFactor;
+ }
+
+ public boolean isShowLabels()
+ {
+ return showLabels;
+ }
+
+ public void setShowLabels(boolean showLabels)
+ {
+ this.showLabels = showLabels;
+ }
+
+ public boolean isApplyToAllViews()
+ {
+ return applyToAllViews;
+ }
+
+ public void setApplyToAllViews(boolean applyToAllViews)
+ {
+ this.applyToAllViews = applyToAllViews;
+ }
+
+ public Point[] getAxisEndPoints()
+ {
+ return axisEndPoints;
+ }
+
+ public void setAxisEndPoints(Point[] axisEndPoints)
+ {
+ this.axisEndPoints = axisEndPoints;
+ }
+
+ public Color getBgColour()
+ {
+ return bgColour;
+ }
+
+ public void setBgColour(Color bgColour)
+ {
+ this.bgColour = bgColour;
+ }
}