Ejemplo n.º 1
0
 protected void drawRect(
     PoGraSS g, int rX, int rY, int rW, int rH, Color fillColor, Color borderColor) {
   if (filled && fillColor != null) {
     g.setColor(fillColor);
     g.fillRect(rX, rY, rW, rH);
   }
   if (borderColor != null) {
     g.setColor(borderColor);
     g.drawRect(rX, rY, rW, rH);
   }
 }
Ejemplo n.º 2
0
  protected void brushRect(
      PoGraSS g, SMarkerInterface m, int orientation, Rectangle r, Color borderColor) {
    int rX = r.x, rY = r.y, rW = r.width, rH = r.height;
    final double totW = rW;
    final double totH = rH;
    int mark = -1;
    int shift = 0;
    boolean hasAny = false;

    double totalProp = 0;
    double[] props = new double[m.getMaxMark() + 2];
    for (int i = -1; i <= m.getMaxMark(); i++) {
      props[i + 1] = getMarkedProportion(m, i, true);
      totalProp += props[i + 1];
    }
    if (totalProp >= 0.0000001) {
      final int hw = (((orientation & 1) == 0) ? rH : rW);

      pieces = roundProportions(props, totalProp, hw);
      for (int i = -1; i <= m.getMaxMark(); i++) {
        if (props[i + 1] > 0d) {
          hasAny = true;
          if (orientation == 0) { // bottom-up
            rH = pieces[i + 1];
            rY = r.y + r.height - shift - pieces[i + 1];
          } else if (orientation == 2) { // top-down
            rH = pieces[i + 1];
            rY = r.y + shift;
          } else if (orientation == 1) { // left-right
            rW = pieces[i + 1];
            rX = r.x + shift;
          } else if (orientation == 3) { // right-left
            rW = pieces[i + 1];
            rX = r.x + r.width - shift - pieces[i + 1];
          }
          shift += pieces[i + 1];
          g.setColor((i == -1) ? fillColorSel : ColorBridge.getMain().getColor(i));
          g.fillRect(rX, rY, rW, rH);
        }
      }
    }

    if (hasAny) drawRect(g, r, null, borderColor);
  }
Ejemplo n.º 3
0
  public void paintSelected(final PoGraSS g, int orientation, final SMarkerInterface m) {
    if (r == null) return;
    // TODO: this is really ugly and should be done better
    // so orientation has to be moved to plotprimitives
    if (!useCanvasOrientation) orientation = this.orientation;

    final double sa = getMarkedProportion(m, -1);
    if (sa > 0d) {
      boolean hasAny = false;
      if (!allowColorBrushing || !isBrushed(m)) { // no color brushing
        int rX = r.x, rY = r.y, rW = r.width - 1, rH = r.height - 1;

        hasAny = true;
        switch (orientation) {
          case 0:
            rH = getPropSize(rH, sa);
            rY += r.height - rH;
            rX++;
            break;
          case 1:
            rW = getPropSize(rW, sa);
            rX++;
            rY++;
            break;
          case 2:
            rH = getPropSize(rH, sa);
            rX++;
            rY++;
            break;
          case 3:
            rW = getPropSize(rW, sa);
            rX += r.width - rW;
            rY++;
            break;
        }

        drawRect(g, rX, rY, rW, rH, fillColorSel, null);
      } else { // color brushing
        int rX = r.x, rY = r.y, rW = r.width, rH = r.height;
        final double totW = rW;
        final double totH = rH;
        int mark = -1;
        int shift = 0;

        if (pieces != null) {
          /* old code for "zebra hiliting"
          for(int i=0; i<=m.getMaxMark(); i++){
              if (pieces[i]>0) {
                  double rmp = getRelativeMarkedProportion(m,i);
                  if (rmp>0d){
                      hasAny=true;
                      if (orientation==0) { // bottom-up
                          rH=getPropSize(pieces[i],rmp);
                          rY=r.y+r.height-shift-rH;
                      } else if (orientation==2) { // top-down
                          rH=getPropSize(pieces[i],rmp);
                          rY=r.y+shift;
                      } else if (orientation==1) { // left-right
                          rW=getPropSize(pieces[i],rmp);
                          rX=r.x+shift;
                      } else if (orientation==3) { // right-left
                          rW=getPropSize(pieces[i],rmp);
                          rX=r.x+r.width-shift-rW;
                      }
                      g.setColor(fillColorSel);
                      g.fillRect(rX,rY,rW,rH);
                  }
                  shift+=pieces[i];
              }
          }
           */
        }
      }
      if (hasAny) {
        g.setColor(borderColorSel);
        g.drawRect(r.x, r.y, r.width, r.height);
      }
    }
  }