예제 #1
0
 public void draw(ComponentDrawContext context) {
   CircuitState state = context.getCircuitState();
   Graphics g = context.getGraphics();
   GraphicsUtil.switchToWidth(g, WIDTH);
   g.setColor(state.getValue(e0).getColor());
   g.drawLine(e0.getX(), e0.getY(), e1.getX(), e1.getY());
 }
예제 #2
0
 @Override
 public void paintIcon(ComponentDrawContext c, int x, int y) {
   Graphics g = c.getGraphics();
   if (toolIcon != null) {
     toolIcon.paintIcon(c.getDestination(), g, x + 2, y + 2);
   } else {
     int[] xp = {x + 5, x + 5, x + 9, x + 12, x + 14, x + 11, x + 16};
     int[] yp = {y, y + 17, y + 12, y + 18, y + 18, y + 12, y + 12};
     g.setColor(java.awt.Color.black);
     g.fillPolygon(xp, yp, xp.length);
   }
 }
예제 #3
0
 static void drawALUIcon(ComponentDrawContext context, int x, int y) {
   Graphics g = context.getGraphics();
   g.setColor(Color.BLACK);
   int xp[] = {x, x + 15, x + 15, x, x, x + 3, x};
   int yp[] = {y, y + 5, y + 10, y + 15, y + 10, y + 8, y + 6};
   g.drawPolygon(xp, yp, 7);
 }
예제 #4
0
 public InstanceData getData() {
   CircuitState circState = context.getCircuitState();
   if (circState == null || comp == null) {
     throw new UnsupportedOperationException("setData on InstancePainter");
   } else {
     return (InstanceData) circState.getData(comp);
   }
 }
예제 #5
0
 public void setData(InstanceData value) {
   CircuitState circState = context.getCircuitState();
   if (circState == null || comp == null) {
     throw new UnsupportedOperationException("setData on InstancePainter");
   } else {
     circState.setData(comp, value);
   }
 }
예제 #6
0
 public Value getPortValue(int portIndex) {
   InstanceComponent c = comp;
   CircuitState s = context.getCircuitState();
   if (c != null && s != null) {
     return s.getValue(c.getEnd(portIndex).getLocation());
   } else {
     return Value.UNKNOWN;
   }
 }
예제 #7
0
 public void draw(ComponentDrawContext context) {
   drawALU(context.getGraphics(), getBounds());
   context.drawPin(this, 0, "A", Direction.EAST);
   context.drawPin(this, 1, "B", Direction.EAST);
   context.drawPin(this, 3, "Zero", Direction.WEST);
   context.drawPin(this, 4, "Res", Direction.WEST);
   context.drawPin(this, 5, "  OF ", Direction.WEST);
   context.getGraphics().setColor(Color.GRAY);
   context.drawPin(this, 2, "Op", Direction.SOUTH);
   context.getGraphics().setColor(Color.BLACK);
 }
예제 #8
0
 public void drawHandles() {
   context.drawHandles(comp);
 }
예제 #9
0
 public void drawPort(int i) {
   context.drawPin(comp, i);
 }
예제 #10
0
 public long getTickCount() {
   return context.getCircuitState().getPropagator().getTickCount();
 }
예제 #11
0
 public void drawHandle(Location loc) {
   context.drawHandle(loc);
 }
예제 #12
0
  @Override
  public void draw(Canvas canvas, ComponentDrawContext context) {
    Project proj = canvas.getProject();
    int dx = curDx;
    int dy = curDy;
    if (state == MOVING) {
      proj.getSelection().drawGhostsShifted(context, dx, dy);

      MoveGesture gesture = moveGesture;
      if (gesture != null && drawConnections && (dx != 0 || dy != 0)) {
        MoveResult result = gesture.findResult(dx, dy);
        if (result != null) {
          Collection<Wire> wiresToAdd = result.getWiresToAdd();
          Graphics g = context.getGraphics();
          GraphicsUtil.switchToWidth(g, 3);
          g.setColor(Color.GRAY);
          for (Wire w : wiresToAdd) {
            Location loc0 = w.getEnd0();
            Location loc1 = w.getEnd1();
            g.drawLine(loc0.getX(), loc0.getY(), loc1.getX(), loc1.getY());
          }
          GraphicsUtil.switchToWidth(g, 1);
          g.setColor(COLOR_UNMATCHED);
          for (Location conn : result.getUnconnectedLocations()) {
            int connX = conn.getX();
            int connY = conn.getY();
            g.fillOval(connX - 3, connY - 3, 6, 6);
            g.fillOval(connX + dx - 3, connY + dy - 3, 6, 6);
          }
        }
      }
    } else if (state == RECT_SELECT) {
      int left = start.getX();
      int right = left + dx;
      if (left > right) {
        int i = left;
        left = right;
        right = i;
      }
      int top = start.getY();
      int bot = top + dy;
      if (top > bot) {
        int i = top;
        top = bot;
        bot = i;
      }

      Graphics gBase = context.getGraphics();
      int w = right - left - 1;
      int h = bot - top - 1;
      if (w > 2 && h > 2) {
        gBase.setColor(BACKGROUND_RECT_SELECT);
        gBase.fillRect(left + 1, top + 1, w - 1, h - 1);
      }

      Circuit circ = canvas.getCircuit();
      Bounds bds = Bounds.create(left, top, right - left, bot - top);
      for (Component c : circ.getAllWithin(bds)) {
        Location cloc = c.getLocation();
        Graphics gDup = gBase.create();
        context.setGraphics(gDup);
        c.getFactory()
            .drawGhost(context, COLOR_RECT_SELECT, cloc.getX(), cloc.getY(), c.getAttributeSet());
        gDup.dispose();
      }

      gBase.setColor(COLOR_RECT_SELECT);
      GraphicsUtil.switchToWidth(gBase, 2);
      if (w < 0) w = 0;
      if (h < 0) h = 0;
      gBase.drawRect(left, top, w, h);
    }
  }
예제 #13
0
 public Object getGateShape() {
   return context.getGateShape();
 }
예제 #14
0
 //
 // helper methods for drawing common elements in components
 //
 public void drawBounds() {
   context.drawBounds(comp);
 }
예제 #15
0
 public void drawRectangle(Bounds bds, String label) {
   context.drawRectangle(bds.getX(), bds.getY(), bds.getWidth(), bds.getHeight(), label);
 }
예제 #16
0
 //
 // methods related to the circuit state
 //
 public Project getProject() {
   return context.getCircuitState().getProject();
 }
예제 #17
0
 public boolean shouldDrawColor() {
   return context.shouldDrawColor();
 }
예제 #18
0
 public boolean isPrintView() {
   return context.isPrintView();
 }
예제 #19
0
 public boolean isPortConnected(int index) {
   Circuit circ = context.getCircuit();
   Location loc = comp.getEnd(index).getLocation();
   return circ.isConnected(loc, comp);
 }
예제 #20
0
 public boolean isCircuitRoot() {
   return !context.getCircuitState().isSubstate();
 }
예제 #21
0
 public void drawPort(int i, String label, Direction dir) {
   context.drawPin(comp, i, label, dir);
 }
예제 #22
0
 //
 // methods related to the context of the canvas
 //
 public WireSet getHighlightedWires() {
   return context.getHighlightedWires();
 }
예제 #23
0
 public void drawPorts() {
   context.drawPins(comp);
 }
예제 #24
0
 public void drawClockSymbol(int xpos, int ypos) {
   context.drawClockSymbol(comp, xpos, ypos);
 }
예제 #25
0
 @Override
 public void draw(Canvas canvas, ComponentDrawContext context) {
   if (caret != null) caret.draw(context.getGraphics());
 }
예제 #26
0
 public void drawDongle(int x, int y) {
   context.drawDongle(x, y);
 }
예제 #27
0
 public Graphics getGraphics() {
   return context.getGraphics();
 }
예제 #28
0
 public void drawHandle(int x, int y) {
   context.drawHandle(x, y);
 }
예제 #29
0
 public void drawClock(int i, Direction dir) {
   context.drawClock(comp, i, dir);
 }
예제 #30
0
 public boolean getShowState() {
   return context.getShowState();
 }