Ejemplo n.º 1
0
 private void init() {
   this.transform_ = this.createJSTransform();
   this.mouseWentDown()
       .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDown(o, e);}}");
   this.mouseWentUp()
       .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseUp(o, e);}}");
   this.mouseDragged()
       .addListener("function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseDrag(o, e);}}");
   this.mouseMoved()
       .addListener(
           "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.mouseMoved(o, e);}}");
   this.touchStarted()
       .addListener(
           "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchStarted(o, e);}}");
   this.touchEnded()
       .addListener(
           "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchEnded(o, e);}}");
   this.touchMoved()
       .addListener(
           "function(o, e){var o=" + this.getSObjJsRef() + ";if(o){o.touchMoved(o, e);}}");
   this.setSelectionAreaPadding(0, EnumSet.of(Side.Top));
   this.setSelectionAreaPadding(20, EnumSet.of(Side.Left, Side.Right));
   this.setSelectionAreaPadding(30, EnumSet.of(Side.Bottom));
   if (this.chart_ != null) {
     this.chart_.addAxisSliderWidget(this);
   }
 }
 private void internalScrollTo(long newX, long newY, boolean moveViewPort) {
   if (this.imageWidth_ != Infinite) {
     newX = Math.min(this.imageWidth_ - this.viewPortWidth_, Math.max((long) 0, newX));
   }
   if (this.imageHeight_ != Infinite) {
     newY = Math.min(this.imageHeight_ - this.viewPortHeight_, Math.max((long) 0, newY));
   }
   if (moveViewPort) {
     this.contents_.setOffsets(new WLength((double) -newX), EnumSet.of(Side.Left));
     this.contents_.setOffsets(new WLength((double) -newY), EnumSet.of(Side.Top));
   }
   this.generateGridItems(newX, newY);
   this.viewPortChanged_.trigger(this.currentX_, this.currentY_);
 }
Ejemplo n.º 3
0
  /**
   * Get the active cipher suites.
   *
   * <p>In TLS 1.1, many weak or vulnerable cipher suites were obsoleted, such as
   * TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT negotiate these cipher suites in
   * TLS 1.1 or later mode.
   *
   * <p>Therefore, when the active protocols only include TLS 1.1 or later, the client cannot
   * request to negotiate those obsoleted cipher suites. That is, the obsoleted suites should not be
   * included in the client hello. So we need to create a subset of the enabled cipher suites, the
   * active cipher suites, which does not contain obsoleted cipher suites of the minimum active
   * protocol.
   *
   * <p>Return empty list instead of null if no active cipher suites.
   */
  CipherSuiteList getActiveCipherSuites() {
    if (activeCipherSuites == null) {
      if (activeProtocols == null) {
        activeProtocols = getActiveProtocols();
      }

      ArrayList<CipherSuite> suites = new ArrayList<>();
      if (!(activeProtocols.collection().isEmpty())
          && activeProtocols.min.v != ProtocolVersion.NONE.v) {
        for (CipherSuite suite : enabledCipherSuites.collection()) {
          if (suite.obsoleted > activeProtocols.min.v && suite.supported <= activeProtocols.max.v) {
            if (algorithmConstraints.permits(
                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) {
              suites.add(suite);
            }
          } else if (debug != null && Debug.isOn("verbose")) {
            if (suite.obsoleted <= activeProtocols.min.v) {
              System.out.println("Ignoring obsoleted cipher suite: " + suite);
            } else {
              System.out.println("Ignoring unsupported cipher suite: " + suite);
            }
          }
        }
      }
      activeCipherSuites = new CipherSuiteList(suites);
    }

    return activeCipherSuites;
  }
Ejemplo n.º 4
0
 void expand(int row, int column, int rowSpan, int columnSpan) {
   int newNumRows = row + rowSpan;
   int curNumColumns = this.getColumnCount();
   int newNumColumns = Math.max(curNumColumns, column + columnSpan);
   if (newNumRows > this.getRowCount() || newNumColumns > curNumColumns) {
     if (newNumColumns == curNumColumns && this.getRowCount() >= this.headerRowCount_) {
       this.rowsAdded_ += newNumRows - this.getRowCount();
     } else {
       this.flags_.set(BIT_GRID_CHANGED);
     }
     this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
     for (int r = this.getRowCount(); r < newNumRows; ++r) {
       this.rows_.add(new WTableRow(this, newNumColumns));
     }
     if (newNumColumns > curNumColumns) {
       for (int r = 0; r < this.getRowCount(); ++r) {
         WTableRow tr = this.rows_.get(r);
         tr.expand(newNumColumns);
       }
       for (int c = curNumColumns; c <= column; ++c) {
         this.columns_.add(new WTableColumn(this));
       }
     }
   }
 }
Ejemplo n.º 5
0
  /*
   * Get the active protocol versions.
   *
   * In TLS 1.1, many weak or vulnerable cipher suites were obsoleted,
   * such as TLS_RSA_EXPORT_WITH_RC4_40_MD5. The implementation MUST NOT
   * negotiate these cipher suites in TLS 1.1 or later mode.
   *
   * For example, if "TLS_RSA_EXPORT_WITH_RC4_40_MD5" is the
   * only enabled cipher suite, the client cannot request TLS 1.1 or
   * later, even though TLS 1.1 or later is enabled.  We need to create a
   * subset of the enabled protocols, called the active protocols, which
   * contains protocols appropriate to the list of enabled Ciphersuites.
   *
   * Return empty list instead of null if no active protocol versions.
   */
  ProtocolList getActiveProtocols() {
    if (activeProtocols == null) {
      ArrayList<ProtocolVersion> protocols = new ArrayList<>(4);
      for (ProtocolVersion protocol : enabledProtocols.collection()) {
        boolean found = false;
        for (CipherSuite suite : enabledCipherSuites.collection()) {
          if (suite.isAvailable()
              && suite.obsoleted > protocol.v
              && suite.supported <= protocol.v) {
            if (algorithmConstraints.permits(
                EnumSet.of(CryptoPrimitive.KEY_AGREEMENT), suite.name, null)) {
              protocols.add(protocol);
              found = true;
              break;
            } else if (debug != null && Debug.isOn("verbose")) {
              System.out.println("Ignoring disabled cipher suite: " + suite + " for " + protocol);
            }
          } else if (debug != null && Debug.isOn("verbose")) {
            System.out.println("Ignoring unsupported cipher suite: " + suite + " for " + protocol);
          }
        }
        if (!found && (debug != null) && Debug.isOn("handshake")) {
          System.out.println("No available cipher suite for " + protocol);
        }
      }
      activeProtocols = new ProtocolList(protocols);
    }

    return activeProtocols;
  }
Ejemplo n.º 6
0
 /** Delete a column and all its contents. */
 public void deleteColumn(int column) {
   for (int i = 0; i < this.getRowCount(); ++i) {
     this.rows_.get(i).deleteColumn(column);
   }
   if ((int) column <= this.columns_.size()) {;
     this.columns_.remove(0 + column);
   }
   this.flags_.set(BIT_GRID_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
Ejemplo n.º 7
0
 /**
  * Adds a widget to the grid.
  *
  * <p>Calls {@link #addWidget(WWidget widget, int row, int column, int rowSpan, int columnSpan,
  * EnumSet alignment) addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen,
  * alignment))}
  */
 public final void addWidget(
     WWidget widget,
     int row,
     int column,
     int rowSpan,
     int columnSpan,
     AlignmentFlag alignmen,
     AlignmentFlag... alignment) {
   addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment));
 }
Ejemplo n.º 8
0
 /**
  * Adds a nested layout item to the grid.
  *
  * <p>Calls {@link #addLayout(WLayout layout, int row, int column, int rowSpan, int columnSpan,
  * EnumSet alignment) addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen,
  * alignment))}
  */
 public final void addLayout(
     WLayout layout,
     int row,
     int column,
     int rowSpan,
     int columnSpan,
     AlignmentFlag alignmen,
     AlignmentFlag... alignment) {
   addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment));
 }
Ejemplo n.º 9
0
 /**
  * Adds a layout item to the grid.
  *
  * <p>Calls {@link #addItem(WLayoutItem item, int row, int column, int rowSpan, int columnSpan,
  * EnumSet alignment) addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen,
  * alignment))}
  */
 public final void addItem(
     WLayoutItem item,
     int row,
     int column,
     int rowSpan,
     int columnSpan,
     AlignmentFlag alignmen,
     AlignmentFlag... alignment) {
   addItem(item, row, column, rowSpan, columnSpan, EnumSet.of(alignmen, alignment));
 }
Ejemplo n.º 10
0
 void repaintRow(WTableRow row) {
   if (row.getRowNum() >= (int) (this.getRowCount() - this.rowsAdded_)) {
     return;
   }
   if (!(this.rowsChanged_ != null)) {
     this.rowsChanged_ = new HashSet<WTableRow>();
   }
   this.rowsChanged_.add(row);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
Ejemplo n.º 11
0
 /** Inserts an empty row. */
 public WTableRow insertRow(int row) {
   if (row >= this.getRowCount()) {
     return this.getRowAt(row);
   } else {
     WTableRow tableRow = new WTableRow(this, this.getColumnCount());
     this.rows_.add(0 + row, tableRow);
     this.flags_.set(BIT_GRID_CHANGED);
     this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
     return tableRow;
   }
 }
 private void generateGridItems(long newX, long newY) {
   WVirtualImage.Rect newNb =
       this.neighbourhood(newX, newY, this.viewPortWidth_, this.viewPortHeight_);
   long i1 = newNb.x1 / this.gridImageSize_;
   long j1 = newNb.y1 / this.gridImageSize_;
   long i2 = newNb.x2 / this.gridImageSize_ + 1;
   long j2 = newNb.y2 / this.gridImageSize_ + 1;
   for (int invisible = 0; invisible < 2; ++invisible) {
     for (long i = i1; i < i2; ++i) {
       for (long j = j1; j < j2; ++j) {
         long key = this.gridKey(i, j);
         WImage it = this.grid_.get(key);
         if (it == null) {
           boolean v = this.visible(i, j);
           if (v && !(invisible != 0) || !v && invisible != 0) {
             long brx = i * this.gridImageSize_ + this.gridImageSize_;
             long bry = j * this.gridImageSize_ + this.gridImageSize_;
             brx = Math.min(brx, this.imageWidth_);
             bry = Math.min(bry, this.imageHeight_);
             WImage img =
                 this.createImage(
                     i * this.gridImageSize_,
                     j * this.gridImageSize_,
                     (int) (brx - i * this.gridImageSize_),
                     (int) (bry - j * this.gridImageSize_));
             img.setAttributeValue("onmousedown", "return false;");
             this.contents_.addWidget(img);
             img.setPositionScheme(PositionScheme.Absolute);
             img.setOffsets(new WLength((double) i * this.gridImageSize_), EnumSet.of(Side.Left));
             img.setOffsets(new WLength((double) j * this.gridImageSize_), EnumSet.of(Side.Top));
             this.grid_.put(key, img);
           }
         }
       }
     }
   }
   this.currentX_ = newX;
   this.currentY_ = newY;
   this.cleanGrid();
 }
Ejemplo n.º 13
0
 /** Inserts an empty column. */
 public WTableColumn insertColumn(int column) {
   for (int i = 0; i < this.rows_.size(); ++i) {
     this.rows_.get(i).insertColumn(column);
   }
   WTableColumn tableColumn = null;
   if ((int) column <= this.columns_.size()) {
     tableColumn = new WTableColumn(this);
     this.columns_.add(0 + column, tableColumn);
   }
   this.flags_.set(BIT_GRID_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
   return tableColumn;
 }
Ejemplo n.º 14
0
 /**
  * Move a table row from its original position to a new position.
  *
  * <p>The table expands automatically when the <code>to</code> row is beyond the current table
  * dimensions.
  *
  * <p>
  *
  * @see WTable#moveColumn(int from, int to)
  */
 public void moveRow(int from, int to) {
   if (from < 0 || from >= (int) this.rows_.size()) {
     logger.error(
         new StringWriter()
             .append("moveRow: the from index is not a valid row index.")
             .toString());
     return;
   }
   WTableRow from_tr = this.getRowAt(from);
   this.rows_.remove(from_tr);
   if (to > (int) this.rows_.size()) {
     this.getRowAt(to);
   }
   this.rows_.add(0 + to, from_tr);
   this.flags_.set(BIT_GRID_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
Ejemplo n.º 15
0
 /**
  * Deletes a row and all its contents.
  *
  * <p>Rows below the given row are shifted up.
  */
 public void deleteRow(int row) {
   if (this.rowsChanged_ != null) {
     this.rowsChanged_.remove(this.rows_.get(row));
     if (this.rowsChanged_.isEmpty()) {;
       this.rowsChanged_ = null;
     }
   }
   for (int i = 0; i < this.getColumnCount(); ++i) {
     WTableCell cell = this.rows_.get(row).cells_.get(i).cell;
     if (cell != null) cell.remove();
   }
   if (row >= (int) (this.getRowCount() - this.rowsAdded_)) {
     --this.rowsAdded_;
   } else {
     this.flags_.set(BIT_GRID_CHANGED);
     this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
   }
   ;
   this.rows_.remove(0 + row);
 }
Ejemplo n.º 16
0
 /**
  * Move a table column from its original position to a new position.
  *
  * <p>The table expands automatically when the <code>to</code> column is beyond the current table
  * dimensions.
  *
  * <p>
  *
  * @see WTable#moveRow(int from, int to)
  */
 public void moveColumn(int from, int to) {
   if (from < 0 || from >= (int) this.columns_.size()) {
     logger.error(
         new StringWriter()
             .append("moveColumn: the from index is not a valid column index.")
             .toString());
     return;
   }
   WTableColumn from_tc = this.getColumnAt(from);
   this.columns_.remove(from_tc);
   if (to > (int) this.columns_.size()) {
     this.getColumnAt(to);
   }
   this.columns_.add(0 + to, from_tc);
   for (int i = 0; i < this.rows_.size(); i++) {
     List<WTableRow.TableData> cells = this.rows_.get(i).cells_;
     WTableRow.TableData cell = cells.get(from);
     cells.remove(0 + from);
     cells.add(0 + to, cell);
   }
   this.flags_.set(BIT_GRID_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
Ejemplo n.º 17
0
  @Deprecated
  public static void copy(
      Configuration conf,
      String srcPath,
      String destPath,
      Path logPath,
      boolean srcAsList,
      boolean ignoreReadFailures)
      throws IOException {
    final Path src = new Path(srcPath);
    List<Path> tmp = new ArrayList<Path>();
    if (srcAsList) {
      tmp.addAll(fetchFileList(conf, src));
    } else {
      tmp.add(src);
    }
    EnumSet<Options> flags =
        ignoreReadFailures
            ? EnumSet.of(Options.IGNORE_READ_FAILURES)
            : EnumSet.noneOf(Options.class);

    final Path dst = new Path(destPath);
    copy(conf, new Arguments(tmp, dst, logPath, flags, null, Long.MAX_VALUE, Long.MAX_VALUE, null));
  }
Ejemplo n.º 18
0
 /**
  * Removes all source elements.
  *
  * <p>This method can be used to remove all media sources. Afterward, you may add new media
  * sources with calls to {@link WAbstractMedia#addSource(WLink link, String type, String media)
  * addSource()}.
  *
  * <p>Use this to reuse a {@link WAbstractMedia} instantiation to play something else.
  */
 public void clearSources() {
   for (int i = 0; i < this.sources_.size(); ++i) {;
   }
   this.sources_.clear();
   this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Ejemplo n.º 19
0
 /** Set the preload mode. */
 public void setPreloadMode(WAbstractMedia.PreloadMode mode) {
   this.preloadMode_ = mode;
   this.preloadChanged_ = true;
   this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Ejemplo n.º 20
0
 /**
  * Set the media element options.
  *
  * <p>Calls {@link #setOptions(EnumSet flags) setOptions(EnumSet.of(flag, flags))}
  */
 public final void setOptions(WAbstractMedia.Options flag, WAbstractMedia.Options... flags) {
   setOptions(EnumSet.of(flag, flags));
 }
Ejemplo n.º 21
0
 /**
  * Set the media element options.
  *
  * <p>
  *
  * @see WAbstractMedia.Options
  */
 public void setOptions(EnumSet<WAbstractMedia.Options> flags) {
   this.flags_ = EnumSet.copyOf(flags);
   this.flagsChanged_ = true;
   this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Ejemplo n.º 22
0
 void repaintColumn(WTableColumn column) {
   this.flags_.set(BIT_COLUMNS_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
 public void testEnumSet() throws Exception {
   StringWriter sw = new StringWriter();
   EnumSet<TestEnum> value = EnumSet.of(TestEnum.B);
   mapper.writeValue(sw, value);
   assertEquals("[\"B\"]", sw.toString());
 }
Ejemplo n.º 24
0
 protected void paintEvent(WPaintDevice paintDevice) {
   if (!(this.chart_ != null) || !this.chart_.cObjCreated_) {
     return;
   }
   if (this.chart_.getSeries(this.seriesColumn_).getType() != SeriesType.LineSeries
       && this.chart_.getSeries(this.seriesColumn_).getType() != SeriesType.CurveSeries) {
     if (this.getMethod() == WPaintedWidget.Method.HtmlCanvas) {
       StringBuilder ss = new StringBuilder();
       ss.append("jQuery.removeData(").append(this.getJsRef()).append(",'sobj');");
       ss.append("\nif (")
           .append(this.getObjJsRef())
           .append(") {")
           .append(this.getObjJsRef())
           .append(".canvas.style.cursor = 'auto';")
           .append("setTimeout(")
           .append(this.getObjJsRef())
           .append(".repaint,0);}\n");
       this.doJavaScript(ss.toString());
     }
     logger.error(
         new StringWriter()
             .append("WAxisSliderWidget is not associated with a line or curve series.")
             .toString());
     return;
   }
   WPainter painter = new WPainter(paintDevice);
   boolean horizontal = this.chart_.getOrientation() == Orientation.Vertical;
   double w = horizontal ? this.getWidth().getValue() : this.getHeight().getValue();
   double h = horizontal ? this.getHeight().getValue() : this.getWidth().getValue();
   boolean autoPadding = this.autoPadding_;
   if (autoPadding
       && EnumUtils.mask(paintDevice.getFeatures(), WPaintDevice.FeatureFlag.HasFontMetrics)
           .equals(0)
       && this.labelsEnabled_) {
     logger.error(
         new StringWriter()
             .append(
                 "setAutoLayout(): device does not have font metrics (not even server-side font metrics).")
             .toString());
     autoPadding = false;
   }
   if (autoPadding) {
     if (horizontal) {
       if (this.labelsEnabled_) {
         this.setSelectionAreaPadding(0, EnumSet.of(Side.Top));
         this.setSelectionAreaPadding(
             (int)
                 (this.chart_
                         .getAxis(Axis.XAxis)
                         .calcMaxTickLabelSize(paintDevice, Orientation.Vertical)
                     + 10),
             EnumSet.of(Side.Bottom));
         this.setSelectionAreaPadding(
             (int)
                 Math.max(
                     this.chart_
                             .getAxis(Axis.XAxis)
                             .calcMaxTickLabelSize(paintDevice, Orientation.Horizontal)
                         / 2,
                     10.0),
             EnumSet.of(Side.Left, Side.Right));
       } else {
         this.setSelectionAreaPadding(0, EnumSet.of(Side.Top));
         this.setSelectionAreaPadding(5, EnumSet.of(Side.Left, Side.Right, Side.Bottom));
       }
     } else {
       if (this.labelsEnabled_) {
         this.setSelectionAreaPadding(0, EnumSet.of(Side.Right));
         this.setSelectionAreaPadding(
             (int)
                 Math.max(
                     this.chart_
                             .getAxis(Axis.XAxis)
                             .calcMaxTickLabelSize(paintDevice, Orientation.Vertical)
                         / 2,
                     10.0),
             EnumSet.of(Side.Top, Side.Bottom));
         this.setSelectionAreaPadding(
             (int)
                 (this.chart_
                         .getAxis(Axis.XAxis)
                         .calcMaxTickLabelSize(paintDevice, Orientation.Horizontal)
                     + 10),
             EnumSet.of(Side.Left));
       } else {
         this.setSelectionAreaPadding(0, EnumSet.of(Side.Right));
         this.setSelectionAreaPadding(5, EnumSet.of(Side.Top, Side.Bottom, Side.Left));
       }
     }
   }
   double left =
       horizontal
           ? this.getSelectionAreaPadding(Side.Left)
           : this.getSelectionAreaPadding(Side.Top);
   double right =
       horizontal
           ? this.getSelectionAreaPadding(Side.Right)
           : this.getSelectionAreaPadding(Side.Bottom);
   double top =
       horizontal
           ? this.getSelectionAreaPadding(Side.Top)
           : this.getSelectionAreaPadding(Side.Right);
   double bottom =
       horizontal
           ? this.getSelectionAreaPadding(Side.Bottom)
           : this.getSelectionAreaPadding(Side.Left);
   double maxW = w - left - right;
   WRectF drawArea = new WRectF(left, 0, maxW, h);
   List<WAxis.Segment> segmentsBak =
       new ArrayList<WAxis.Segment>(this.chart_.getAxis(Axis.XAxis).segments_);
   double renderIntervalBak = this.chart_.getAxis(Axis.XAxis).renderInterval_;
   this.chart_
       .getAxis(Axis.XAxis)
       .prepareRender(
           horizontal ? Orientation.Horizontal : Orientation.Vertical, drawArea.getWidth());
   final WRectF chartArea = this.chart_.chartArea_;
   WRectF selectionRect = null;
   {
     double u =
         -this.chart_.xTransformHandle_.getValue().getDx()
             / (chartArea.getWidth() * this.chart_.xTransformHandle_.getValue().getM11());
     selectionRect = new WRectF(0, top, maxW, h - (top + bottom));
     this.transform_.setValue(
         new WTransform(
             1 / this.chart_.xTransformHandle_.getValue().getM11(), 0, 0, 1, u * maxW, 0));
   }
   WRectF seriesArea = new WRectF(left, top + 5, maxW, h - (top + bottom + 5));
   WTransform selectionTransform =
       this.hv(new WTransform(1, 0, 0, 1, left, 0).multiply(this.transform_.getValue()));
   WRectF rect = selectionTransform.map(this.hv(selectionRect));
   painter.fillRect(this.hv(new WRectF(left, top, maxW, h - top - bottom)), this.background_);
   painter.fillRect(rect, this.selectedAreaBrush_);
   final double TICK_LENGTH = 5;
   final double ANGLE1 = 15;
   final double ANGLE2 = 80;
   double tickStart = 0.0;
   double tickEnd = 0.0;
   double labelPos = 0.0;
   AlignmentFlag labelHFlag = AlignmentFlag.AlignCenter;
   AlignmentFlag labelVFlag = AlignmentFlag.AlignMiddle;
   final WAxis axis = this.chart_.getAxis(Axis.XAxis);
   if (horizontal) {
     tickStart = 0;
     tickEnd = TICK_LENGTH;
     labelPos = TICK_LENGTH;
     labelVFlag = AlignmentFlag.AlignTop;
   } else {
     tickStart = -TICK_LENGTH;
     tickEnd = 0;
     labelPos = -TICK_LENGTH;
     labelHFlag = AlignmentFlag.AlignRight;
   }
   if (horizontal) {
     if (axis.getLabelAngle() > ANGLE1) {
       labelHFlag = AlignmentFlag.AlignRight;
       if (axis.getLabelAngle() > ANGLE2) {
         labelVFlag = AlignmentFlag.AlignMiddle;
       }
     } else {
       if (axis.getLabelAngle() < -ANGLE1) {
         labelHFlag = AlignmentFlag.AlignLeft;
         if (axis.getLabelAngle() < -ANGLE2) {
           labelVFlag = AlignmentFlag.AlignMiddle;
         }
       }
     }
   } else {
     if (axis.getLabelAngle() > ANGLE1) {
       labelVFlag = AlignmentFlag.AlignBottom;
       if (axis.getLabelAngle() > ANGLE2) {
         labelHFlag = AlignmentFlag.AlignCenter;
       }
     } else {
       if (axis.getLabelAngle() < -ANGLE1) {
         labelVFlag = AlignmentFlag.AlignTop;
         if (axis.getLabelAngle() < -ANGLE2) {
           labelHFlag = AlignmentFlag.AlignCenter;
         }
       }
     }
   }
   EnumSet<AxisProperty> axisProperties = EnumSet.of(AxisProperty.Line);
   if (this.labelsEnabled_) {
     axisProperties.add(AxisProperty.Labels);
   }
   if (horizontal) {
     axis.render(
         painter,
         axisProperties,
         new WPointF(drawArea.getLeft(), h - bottom),
         new WPointF(drawArea.getRight(), h - bottom),
         tickStart,
         tickEnd,
         labelPos,
         EnumSet.of(labelHFlag, labelVFlag));
     WPainterPath line = new WPainterPath();
     line.moveTo(drawArea.getLeft() + 0.5, h - (bottom - 0.5));
     line.lineTo(drawArea.getRight(), h - (bottom - 0.5));
     painter.strokePath(line, this.chart_.getAxis(Axis.XAxis).getPen());
   } else {
     axis.render(
         painter,
         axisProperties,
         new WPointF(this.getSelectionAreaPadding(Side.Left) - 1, drawArea.getLeft()),
         new WPointF(this.getSelectionAreaPadding(Side.Left) - 1, drawArea.getRight()),
         tickStart,
         tickEnd,
         labelPos,
         EnumSet.of(labelHFlag, labelVFlag));
     WPainterPath line = new WPainterPath();
     line.moveTo(this.getSelectionAreaPadding(Side.Left) - 0.5, drawArea.getLeft() + 0.5);
     line.lineTo(this.getSelectionAreaPadding(Side.Left) - 0.5, drawArea.getRight());
     painter.strokePath(line, this.chart_.getAxis(Axis.XAxis).getPen());
   }
   WPainterPath curve = new WPainterPath();
   {
     WTransform t =
         new WTransform(1, 0, 0, 1, seriesArea.getLeft(), seriesArea.getTop())
             .multiply(
                 new WTransform(
                     seriesArea.getWidth() / chartArea.getWidth(),
                     0,
                     0,
                     seriesArea.getHeight() / chartArea.getHeight(),
                     0,
                     0))
             .multiply(new WTransform(1, 0, 0, 1, -chartArea.getLeft(), -chartArea.getTop()));
     if (!horizontal) {
       t.assign(
           new WTransform(
                   0,
                   1,
                   1,
                   0,
                   this.getSelectionAreaPadding(Side.Left)
                       - this.getSelectionAreaPadding(Side.Right)
                       - 5,
                   0)
               .multiply(t)
               .multiply(new WTransform(0, 1, 1, 0, 0, 0)));
     }
     curve.assign(t.map(this.chart_.pathForSeries(this.seriesColumn_)));
   }
   {
     WRectF leftHandle = this.hv(new WRectF(-5, top, 5, h - top - bottom));
     WTransform t =
         new WTransform(1, 0, 0, 1, left, -top)
             .multiply(
                 new WTransform()
                     .translate(this.transform_.getValue().map(selectionRect.getTopLeft())));
     painter.fillRect(this.hv(t).map(leftHandle), this.handleBrush_);
   }
   {
     WRectF rightHandle = this.hv(new WRectF(0, top, 5, h - top - bottom));
     WTransform t =
         new WTransform(1, 0, 0, 1, left, -top)
             .multiply(
                 new WTransform()
                     .translate(this.transform_.getValue().map(selectionRect.getTopRight())));
     painter.fillRect(this.hv(t).map(rightHandle), this.handleBrush_);
   }
   if (this.selectedSeriesPen_ != this.seriesPen_
       && !this.selectedSeriesPen_.equals(this.seriesPen_)) {
     WPainterPath clipPath = new WPainterPath();
     clipPath.addRect(this.hv(selectionRect));
     painter.setClipPath(selectionTransform.map(clipPath));
     painter.setClipping(true);
     painter.setPen(this.getSelectedSeriesPen());
     painter.drawPath(curve);
     WPainterPath leftClipPath = new WPainterPath();
     leftClipPath.addRect(
         this.hv(new WTransform(1, 0, 0, 1, -selectionRect.getWidth(), 0).map(selectionRect)));
     painter.setClipPath(
         this.hv(
                 new WTransform(1, 0, 0, 1, left, -top)
                     .multiply(
                         new WTransform()
                             .translate(
                                 this.transform_.getValue().map(selectionRect.getTopLeft()))))
             .map(leftClipPath));
     painter.setPen(this.getSeriesPen());
     painter.drawPath(curve);
     WPainterPath rightClipPath = new WPainterPath();
     rightClipPath.addRect(
         this.hv(new WTransform(1, 0, 0, 1, selectionRect.getWidth(), 0).map(selectionRect)));
     painter.setClipPath(
         this.hv(
                 new WTransform(1, 0, 0, 1, left - selectionRect.getRight(), -top)
                     .multiply(
                         new WTransform()
                             .translate(
                                 this.transform_.getValue().map(selectionRect.getTopRight()))))
             .map(rightClipPath));
     painter.drawPath(curve);
     painter.setClipping(false);
   } else {
     painter.setPen(this.getSeriesPen());
     painter.drawPath(curve);
   }
   if (this.getMethod() == WPaintedWidget.Method.HtmlCanvas) {
     WApplication app = WApplication.getInstance();
     StringBuilder ss = new StringBuilder();
     ss.append("new Wt3_3_5.WAxisSliderWidget(")
         .append(app.getJavaScriptClass())
         .append(",")
         .append(this.getJsRef())
         .append(",")
         .append(this.getObjJsRef())
         .append(",")
         .append("{chart:")
         .append(this.chart_.getCObjJsRef())
         .append(",transform:")
         .append(this.transform_.getJsRef())
         .append(",rect:function(){return ")
         .append(rect.getJsRef())
         .append("},drawArea:")
         .append(drawArea.getJsRef())
         .append(",series:")
         .append(this.seriesColumn_)
         .append("});");
     this.doJavaScript(ss.toString());
   }
   Utils.copyList(segmentsBak, this.chart_.getAxis(Axis.XAxis).segments_);
   this.chart_.getAxis(Axis.XAxis).renderInterval_ = renderIntervalBak;
 }
Ejemplo n.º 25
0
 /**
  * Add a media source.
  *
  * <p>This method specifies a media source (which may be a URL or dynamic resource). You may add
  * as many media sources as you want. The browser will select the appropriate media stream to
  * display to the user.
  *
  * <p>This method specifies a media source using the URL, the mime type, and the media attribute.
  * HTML allows for empty type and media attributes.
  */
 public void addSource(WLink link, String type, String media) {
   this.sources_.add(new WAbstractMedia.Source(this, link, type, media));
   this.sourcesChanged_ = true;
   this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Ejemplo n.º 26
0
 public void resourceChanged() {
   this.parent.sourcesChanged_ = true;
   this.parent.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Ejemplo n.º 27
0
  public static JToolBar getToolbar(String label, int size, boolean hasStrings) {
    JToolBar toolBar = new JToolBar();

    JButton buttonCut = new JButton(hasStrings ? "cut" : null, getIcon(size + "/edit-cut"));
    buttonCut.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    toolBar.add(buttonCut);
    JButton buttonCopy = new JButton(hasStrings ? "copy" : null, getIcon(size + "/edit-copy"));
    buttonCopy.putClientProperty(SubstanceLookAndFeel.BUTTON_NO_MIN_SIZE_PROPERTY, Boolean.TRUE);
    buttonCopy.setEnabled(false);
    toolBar.add(buttonCopy);
    JButton buttonPaste = new JButton(getIcon(size + "/edit-paste"));
    toolBar.add(buttonPaste);
    JButton buttonSelectAll = new JButton(getIcon(size + "/edit-select-all"));
    toolBar.add(buttonSelectAll);
    JButton buttonDelete = new JButton(getIcon(size + "/edit-delete"));
    toolBar.add(buttonDelete);
    toolBar.addSeparator();

    // add an inner toolbar to check the painting of toolbar
    // gradient and drop shadows under different skins.
    JToolBar innerToolbar = new JToolBar(JToolBar.HORIZONTAL);
    innerToolbar.setFloatable(false);
    JToggleButton buttonFormatCenter = new JToggleButton(getIcon(size + "/format-justify-center"));
    buttonFormatCenter.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 5.0f);
    innerToolbar.add(buttonFormatCenter);
    JToggleButton buttonFormatLeft = new JToggleButton(getIcon(size + "/format-justify-left"));
    innerToolbar.add(buttonFormatLeft);
    JToggleButton buttonFormatRight = new JToggleButton(getIcon(size + "/format-justify-right"));
    innerToolbar.add(buttonFormatRight);
    JToggleButton buttonFormatFill = new JToggleButton(getIcon(size + "/format-justify-fill"));
    buttonFormatFill.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
    innerToolbar.add(buttonFormatFill);

    toolBar.add(innerToolbar);
    toolBar.addSeparator();

    if (size > 20) {
      JToolBar innerToolbar2 = new JToolBar(JToolBar.HORIZONTAL);
      innerToolbar2.setFloatable(false);

      JPanel innerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      innerToolbar2.add(innerPanel, BorderLayout.CENTER);

      final JToggleButton buttonStyleBold = new JToggleButton(getIcon(size + "/format-text-bold"));
      Set<Side> rightSide = EnumSet.of(Side.RIGHT);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);
      buttonStyleBold.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);

      final JToggleButton buttonStyleItalic =
          new JToggleButton(getIcon(size + "/format-text-italic"));
      buttonStyleItalic.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleItalic.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleUnderline =
          new JToggleButton(getIcon(size + "/format-text-underline"));
      buttonStyleUnderline.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 0.0f);
      buttonStyleUnderline.putClientProperty(
          SubstanceLookAndFeel.BUTTON_OPEN_SIDE_PROPERTY, rightSide);

      final JToggleButton buttonStyleStrikethrough =
          new JToggleButton(getIcon(size + "/format-text-strikethrough"));
      buttonStyleStrikethrough.putClientProperty(
          SubstanceLookAndFeel.BUTTON_SIDE_PROPERTY, EnumSet.of(Side.LEFT));
      buttonStyleStrikethrough.putClientProperty(SubstanceLookAndFeel.CORNER_RADIUS, 3.0f);
      buttonStyleBold.setSelected(true);

      innerPanel.add(buttonStyleBold);
      innerPanel.add(buttonStyleItalic);
      innerPanel.add(buttonStyleUnderline);
      innerPanel.add(buttonStyleStrikethrough);

      toolBar.add(innerToolbar2);
    }

    toolBar.add(Box.createGlue());
    JButton buttonExit = new JButton(getIcon(size + "/process-stop"));
    buttonExit.setToolTipText("Closes the test application");
    buttonExit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            System.exit(0);
          }
        });
    toolBar.add(buttonExit);

    return toolBar;
  }
Ejemplo n.º 28
0
 /**
  * Sets an internal margin for the selection area.
  *
  * <p>Calls {@link #setSelectionAreaPadding(int padding, EnumSet sides)
  * setSelectionAreaPadding(padding, EnumSet.of(side, sides))}
  */
 public final void setSelectionAreaPadding(int padding, Side side, Side... sides) {
   setSelectionAreaPadding(padding, EnumSet.of(side, sides));
 }
Ejemplo n.º 29
0
  @Override
  protected int execute() throws Exception {
    BasicConfigurator.configure();
    logger.setLevel(Level.INFO);

    final ReferenceSequenceFile ref;
    try {
      ref = ReferenceSequenceFileFactory.getReferenceSequenceFile(refFile);
    } catch (Exception e) {
      throw new UserException("Couldn't load provided reference sequence file " + refFile, e);
    }

    variant = parseVariantList(variant);

    Comparator<Pair<Integer, File>> positionComparator = new PositionComparator();

    Queue<Pair<Integer, File>> priorityQueue;
    if (assumeSorted) priorityQueue = new LinkedList<>();
    else priorityQueue = new PriorityQueue<>(10000, positionComparator);

    FileType fileType = null;
    for (File file : variant) {
      // if it returns a valid type, it will be the same for all files
      fileType = fileExtensionCheck(file, fileType);
      if (fileType == FileType.INVALID) return 1;

      if (assumeSorted) {
        priorityQueue.add(new Pair<>(0, file));
      } else {
        if (!file.exists()) {
          throw new UserException(String.format("File %s doesn't exist", file.getAbsolutePath()));
        }
        FeatureReader<VariantContext> reader = getFeatureReader(fileType, file);
        Iterator<VariantContext> it = reader.iterator();
        if (!it.hasNext()) {
          System.err.println(
              String.format("File %s is empty. This file will be ignored", file.getAbsolutePath()));
          continue;
        }
        VariantContext vc = it.next();
        int firstPosition = vc.getStart();
        reader.close();
        priorityQueue.add(new Pair<>(firstPosition, file));
      }
    }

    FileOutputStream outputStream = new FileOutputStream(outputFile);
    EnumSet<Options> options = EnumSet.of(Options.INDEX_ON_THE_FLY);
    IndexCreator idxCreator =
        GATKVCFUtils.makeIndexCreator(
            variant_index_type, variant_index_parameter, outputFile, ref.getSequenceDictionary());
    final VariantContextWriter outputWriter =
        VariantContextWriterFactory.create(
            outputFile, outputStream, ref.getSequenceDictionary(), idxCreator, options);

    boolean firstFile = true;
    int count = 0;
    while (!priorityQueue.isEmpty()) {
      count++;
      File file = priorityQueue.remove().getSecond();
      if (!file.exists()) {
        throw new UserException(String.format("File %s doesn't exist", file.getAbsolutePath()));
      }
      FeatureReader<VariantContext> reader = getFeatureReader(fileType, file);

      if (count % 10 == 0) System.out.print(count);
      else System.out.print(".");
      if (firstFile) {
        VCFHeader header = (VCFHeader) reader.getHeader();
        outputWriter.writeHeader(header);
        firstFile = false;
      }

      Iterator<VariantContext> it = reader.iterator();

      while (it.hasNext()) {
        VariantContext vc = it.next();
        outputWriter.add(vc);
      }

      reader.close();
    }
    System.out.println();

    outputWriter.close();

    return 0;
  }