コード例 #1
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 public static void drawImage(int[][][] pixels, int startX, int startY) {
   // Key idea: draw a bunch (lots of rectangles) with the appropriate color
   DrawObject R = new DrawObject();
   R.pixels = pixels;
   R.startX = startX;
   R.startY = startY;
   R.sequenceNum = currentSequenceNum;
   images.add(R);
   // Rescale if needed.
   int leftX = startX;
   int rightX = startX + pixels.length;
   int lowY = startY;
   int highY = startY + pixels[0].length;
   if (minX > leftX) {
     minX = leftX;
   }
   if (maxX < rightX) {
     maxX = rightX;
   }
   if (minY > lowY) {
     minY = lowY;
   }
   if (maxY < highY) {
     maxY = highY;
   }
   drawArea.repaint();
 }
コード例 #2
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
コード例 #3
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 public static void drawLine(double x1, double y1, double x2, double y2, boolean isArrow) {
   DrawObject L = new DrawObject();
   L.color = lineColor;
   L.x = x1;
   L.y = y1;
   L.x2 = x2;
   L.y2 = y2;
   if (isArrow) {
     L.color = arrowColor;
     L.isArrow = true;
   }
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   if (animationMode) {
     synchronized (animLines) {
       animLines.add(L);
     }
   } else {
     synchronized (lines) {
       lines.add(L);
     }
   }
   drawArea.repaint();
 }
コード例 #4
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 public static void drawLineFromEquation(double a, double b, double c) {
   // Draw the equation ax+by+c=0 in the available range.
   DrawObject L = new DrawObject();
   L.color = lineEqnColor;
   L.a = a;
   L.b = b;
   L.c = c;
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   synchronized (eqnLines) {
     eqnLines.add(L);
   }
   drawArea.repaint();
 }
コード例 #5
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 public static void drawRectangle(double x1, double y1, double width, double height) {
   DrawObject R = new DrawObject();
   R.color = rectangleColor;
   R.x = x1;
   R.y = y1;
   R.width = width;
   R.height = height;
   R.sequenceNum = currentSequenceNum;
   R.drawStroke = drawStroke;
   if (animationMode) {
     synchronized (animRectangles) {
       animRectangles.add(R);
     }
   } else {
     synchronized (rectangles) {
       rectangles.add(R);
     }
   }
   drawArea.repaint();
 }
コード例 #6
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 public static void drawLabel(double x, double y, String str) {
   DrawObject L = new DrawObject();
   L.color = labelColor;
   L.x = x;
   L.y = y;
   L.str = str;
   L.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animLabels) {
       animLabels.add(L);
     }
   } else {
     synchronized (labels) {
       labels.add(L);
     }
   }
   drawArea.repaint();
 }
コード例 #7
0
ファイル: DrawTool.java プロジェクト: tstamler/linAlg
 public static void drawPoint(double x, double y) {
   DrawObject p = new DrawObject();
   p.color = pointColor;
   p.x = x;
   p.y = y;
   p.diameter = pointDiameter;
   p.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animPoints) {
       animPoints.add(p);
     }
   } else {
     synchronized (points) {
       points.add(p);
     }
   }
   drawArea.repaint();
 }