Exemple #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_);
 }
 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));
       }
     }
   }
 }
Exemple #4
0
 /**
  * Consctructor for a media widget.
  *
  * <p>A freshly constructed media widget has no options set, no media sources, and has preload
  * mode set to PreloadAuto.
  */
 public WAbstractMedia(WContainerWidget parent) {
   super(parent);
   this.sources_ = new ArrayList<WAbstractMedia.Source>();
   this.sourcesRendered_ = 0;
   this.mediaId_ = "";
   this.flags_ = EnumSet.noneOf(WAbstractMedia.Options.class);
   this.preloadMode_ = WAbstractMedia.PreloadMode.PreloadAuto;
   this.alternative_ = null;
   this.flagsChanged_ = false;
   this.preloadChanged_ = false;
   this.sourcesChanged_ = false;
   this.playing_ = false;
   this.volume_ = -1;
   this.current_ = -1;
   this.duration_ = -1;
   this.ended_ = false;
   this.readyState_ = WAbstractMedia.ReadyState.HaveNothing;
   this.setInline(false);
   this.setFormObject(true);
   WApplication app = WApplication.getInstance();
   app.loadJavaScript("js/WAbstractMedia.js", wtjs1());
   this.setJavaScriptMember(
       " WAbstractMedia",
       "new Wt3_2_3.WAbstractMedia(" + app.getJavaScriptClass() + "," + this.getJsRef() + ");");
 }
Exemple #5
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));
 }
 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));
 }
 /** 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));
 }
Exemple #8
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));
 }
Exemple #9
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));
 }
 /** 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();
 }
 /** 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;
 }
 /**
  * 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));
 }
 /**
  * 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);
 }
Exemple #15
0
 /**
  * Adds a layout item to the grid.
  *
  * <p>Adds the <i>item</i> at (<i>row</i>, <code>column</code>). If an item was already added to
  * that location, it is replaced (but not deleted).
  *
  * <p>An item may span several more rows or columns, which is controlled by <i>rowSpan</i> and
  * <code>columnSpan</code>.
  *
  * <p>The <code>alignment</code> specifies the vertical and horizontal alignment of the item. The
  * default value 0 indicates that the item is stretched to fill the entire grid cell. The
  * alignment can be specified as a logical combination of a horizontal alignment ( {@link
  * AlignmentFlag#AlignLeft}, {@link AlignmentFlag#AlignCenter}, or {@link
  * AlignmentFlag#AlignRight}) and a vertical alignment ( {@link AlignmentFlag#AlignTop}, {@link
  * AlignmentFlag#AlignMiddle}, or {@link AlignmentFlag#AlignBottom}).
  *
  * <p>
  *
  * @see WGridLayout#addLayout(WLayout layout, int row, int column, EnumSet alignment)
  * @see WGridLayout#addWidget(WWidget widget, int row, int column, EnumSet alignment)
  */
 public void addItem(
     WLayoutItem item,
     int row,
     int column,
     int rowSpan,
     int columnSpan,
     EnumSet<AlignmentFlag> alignment) {
   columnSpan = Math.max(1, columnSpan);
   rowSpan = Math.max(1, rowSpan);
   this.expand(row, column, rowSpan, columnSpan);
   final Grid.Item gridItem = this.grid_.items_.get(row).get(column);
   if (gridItem.item_ != null) {
     WLayoutItem oldItem = gridItem.item_;
     gridItem.item_ = null;
     this.updateRemoveItem(oldItem);
   }
   gridItem.item_ = item;
   gridItem.rowSpan_ = rowSpan;
   gridItem.colSpan_ = columnSpan;
   gridItem.alignment_ = EnumSet.copyOf(alignment);
   this.updateAddItem(item);
 }
 /**
  * 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));
 }
Exemple #17
0
 public void resourceChanged() {
   this.parent.sourcesChanged_ = true;
   this.parent.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Exemple #18
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));
 }
Exemple #19
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));
 }
Exemple #20
0
 /** Set the preload mode. */
 public void setPreloadMode(WAbstractMedia.PreloadMode mode) {
   this.preloadMode_ = mode;
   this.preloadChanged_ = true;
   this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute));
 }
Exemple #21
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));
 }
Exemple #22
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));
 }
 void repaintColumn(WTableColumn column) {
   this.flags_.set(BIT_COLUMNS_CHANGED);
   this.repaint(EnumSet.of(RepaintFlag.RepaintInnerHtml));
 }
Exemple #24
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.noneOf(AlignmentFlag.class))}
  */
 public final void addLayout(WLayout layout, int row, int column, int rowSpan, int columnSpan) {
   addLayout(layout, row, column, rowSpan, columnSpan, EnumSet.noneOf(AlignmentFlag.class));
 }
Exemple #25
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.noneOf(AlignmentFlag.class))}
  */
 public final void addItem(WLayoutItem item, int row, int column, int rowSpan, int columnSpan) {
   addItem(item, row, column, rowSpan, columnSpan, EnumSet.noneOf(AlignmentFlag.class));
 }
Exemple #26
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;
 }
Exemple #27
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));
 }
Exemple #28
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.noneOf(AlignmentFlag.class))}
  */
 public final void addWidget(WWidget widget, int row, int column, int rowSpan, int columnSpan) {
   addWidget(widget, row, column, rowSpan, columnSpan, EnumSet.noneOf(AlignmentFlag.class));
 }