/** * */ package analyze; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; /** * @author John H. Krantz * version 0.1 * */ public class PlotLines { public PlotLines(){} // empty constructor public double [] plotLines(Graphics2D g2d, Rectangle2D rfLoc, double val, double peakOrient, double maxVal, double minVal, boolean weightLines, double threshold, boolean weightFromThresh){ g2d.setPaint(Color.white); float stk = 0; // find the cter of the box double ctrX = rfLoc.getCenterX(); double ctrY = rfLoc.getCenterY(); double agl = Math.PI*peakOrient/180.0; double hs = rfLoc.getHeight()/2; // determine the weight of the line g2d.setStroke(new BasicStroke(1.0f)); if (weightLines & agl >= 0){ stk = (float)(val/maxVal); if (weightFromThresh){ stk = (float)((val-threshold)/(maxVal-threshold)); } if (stk <= 0) stk = 0; g2d.setPaint(new Color(stk,stk,stk)); } if (agl < 0){ g2d.setPaint(Color.red); // agl = -(agl-Math.PI); // line weights for negative angles if (weightLines){ stk = (float)(-val/-minVal); if (weightFromThresh){ stk = (float)(((-val)-threshold)/((-minVal)-threshold)); } if (stk <= 0) stk = 0; g2d.setPaint(new Color(stk,0.0f,0.0f)); } } // move to the center of the box being drawn g2d.translate(ctrX,ctrY); // rotate the angle g2d.rotate(agl); // draw the line g2d.draw(new Line2D.Double( 0,-hs,0,+hs)); // rotate back g2d.rotate(-agl); // move back to upter left g2d.translate(-ctrX,-ctrY); double [] output = new double [2]; output[PlotOutput.ANGLE] = peakOrient; output[PlotOutput.ACTIVITY] = val; return output; } // end drawing line }