⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chartcomponent.java

📁 OLAP 的客户端代码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
					null,
					new DrillThroughHandler((Cell) cells.get(cellpos)));

				boolean firstParameter = url.indexOf("?") == -1;
				url += firstParameter ? "?" : "&";
				url += id;
				return url;
			}
			else {
				return null;
			}
		}
        }

	/**
	 * A URLGenerator class to generate chart urls that work with jpivot
	 * @author robin
	 *
	 */
	public class jpivotCategoryURLGenerator extends StandardCategoryURLGenerator {

		/** Prefix to the URL */
		private String prefix = "";

		/** Series parameter name to go in each URL */
		private String seriesParameterName = "col";

		/** Category parameter name to go in each URL */
		private String categoryParameterName = "row";

		private List cells = result.getCells();

		jpivotCategoryURLGenerator() {
		}

		jpivotCategoryURLGenerator(String prefix) {
			this.prefix = prefix;
		}
		/**
		 * Implementation of generateURL that integrates with jpivot/wcf framework.
		 * A request handler is added for each cell/item.
		 * No test is done to see if a cell is drillable, since the url has to added (I think, like an all or nothing ?)
		 * Generates a URL for a particular item within a series.
		 *
		 * @param data  the dataset.
		 * @param series  the series index (zero-based).
		 * @param category  the category index (zero-based).
		 *
		 * @return the generated URL
		 */
		public String generateURL(CategoryDataset data, int series, int category) {
			String url = prefix;
			// convert col, row into ordinal
			// series is col, category is row
			// (reverese terminology to jfreechart, that way series on measures which is more logical)
			int cellpos = (category * colCount) + series;
			if ( canDrillThrough((Cell) cells.get(cellpos)) && (!((Cell) cells.get(cellpos)).isNull()) ) {
				String id = DomUtils.randomId();
				dispatcher.addRequestListener(
					id,
					null,
					new DrillThroughHandler((Cell) cells.get(cellpos)));

				boolean firstParameter = url.indexOf("?") == -1;
				url += firstParameter ? "?" : "&";
				url += id;
				return url;
			}
			else {
				return null;
			}
		}
	}

	/**
	 * request handler for chart drill through
	 * does nothing if cell can't be drilled through (e.g. calculated measure)
	 * @author robin
	 *
	 */
//	class DrillThroughHandler implements RequestListener {
//		Cell cell;
//		DrillThroughHandler(Cell cell) {
//			this.cell = cell;
//		}
//		public void request(RequestContext context) throws Exception {
//
//			if ( canDrillThrough(cell) ) {
//
//				HttpSession session = context.getSession();
//				final String drillTableRef = olapModel.getID() + ".drillthroughtable";
//				com.tonbeller.wcf.table.TableComponent tc =
//							(com.tonbeller.wcf.table.TableComponent)
//							session.getAttribute(drillTableRef);
//				// get a new drill through table model
//				TableModel tm = drillThrough(cell);
//
//				// need to create a new table model for each drill through request
//				// because table model creates an array of columns
//				tc = new com.tonbeller.wcf.table.TableComponent(drillTableRef, tm);
//				tc.initialize(context);
//				((DefaultSelectionModel) tc.getSelectionModel()).setMode(SelectionModel.NO_SELECTION);
//				session.setAttribute(drillTableRef, tc);
//				tc.setVisible(true);
//			}
//		}
//	}
	class DrillThroughHandler implements RequestListener {
		Cell cell;
		DrillThroughHandler(Cell cell) {
			this.cell = cell;
		}
		public void request(RequestContext context) throws Exception {

			if ( canDrillThrough(cell) ) {

				HttpSession session = context.getSession();
				final String drillTableRef = olapModel.getID() + ".drillthroughtable";
				ITableComponent tc =
				  (ITableComponent) session.getAttribute(drillTableRef);
				// get a new drill through table model
				TableModel tm = drillThrough(cell);
				tc.setModel(tm);
				tc.setVisible(true);
			}
		}
	}

	protected boolean canDrillThrough(Cell cell) {
		return ((DrillThrough) olapModel.getExtension(DrillThrough.ID)).canDrillThrough((Cell) cell.getRootDecoree());
	}

	/**
	 * returns a DrillThroughTableModel for the drill through
	 * @param cell
	 * @return
	 */
	protected TableModel drillThrough(Cell cell) {
		return ((DrillThrough) olapModel.getExtension(DrillThrough.ID)).drillThrough((Cell) cell.getRootDecoree());
	}

	public boolean isDrillThroughEnabled() {
		return drillThroughEnabled;
	}

	public void setDrillThroughEnabled(boolean drillThroughEnabled) {
		this.drillThroughEnabled = drillThroughEnabled;
	}

	/**
	 * @return
	 */
	public String getAxisFontName() {
		return axisFontName;
	}

	/**
	 * @param axisFontName
	 */
	public void setAxisFontName(String axisFontName) {
		this.axisFontName = axisFontName;
	}

	/**
	 * @return
	 */
	public int getAxisFontSize() {
		return axisFontSize;
	}

	/**
	 * @param axisFontSize
	 */
	public void setAxisFontSize(int axisFontSize) {
		this.axisFontSize = axisFontSize;
	}

	/**
	 * @return
	 */
	public int getAxisFontStyle() {
		return axisFontStyle;
	}

	/**
	 * @param axisFontStyle
	 */
	public void setAxisFontStyle(int axisFontStyle) {
		this.axisFontStyle = axisFontStyle;
	}

	/**
	 * @return
	 */
	public String getLegendFontName() {
		return legendFontName;
	}

	/**
	 * @param legendFontName
	 */
	public void setLegendFontName(String legendFontName) {
		this.legendFontName = legendFontName;
	}

	/**
	 * @return
	 */
	public int getLegendFontSize() {
		return legendFontSize;
	}

	/**
	 * @param legendFontSize
	 */
	public void setLegendFontSize(int legendFontSize) {
		this.legendFontSize = legendFontSize;
	}

	/**
	 * @return
	 */
	public int getLegendFontStyle() {
		return legendFontStyle;
	}

	/**
	 * @param legendFontStyle
	 */
	public void setLegendFontStyle(int legendFontStyle) {
		this.legendFontStyle = legendFontStyle;
	}

	/**
	 * @return
	 */
	public int getSlicerAlignment() {
		return slicerAlignment;
	}

	/**
	 * @param slicerAlignment
	 */
	public void setSlicerAlignment(int slicerAlignment) {
		this.slicerAlignment = slicerAlignment;
	}

	/**
	 * @return
	 */
	public String getSlicerFontName() {
		return slicerFontName;
	}

	/**
	 * @param slicerFontName
	 */
	public void setSlicerFontName(String slicerFontName) {
		this.slicerFontName = slicerFontName;
	}

	/**
	 * @return
	 */
	public int getSlicerFontSize() {
		return slicerFontSize;
	}

	/**
	 * @param slicerFontSize
	 */
	public void setSlicerFontSize(int slicerFontSize) {
		this.slicerFontSize = slicerFontSize;
	}

	/**
	 * @return
	 */
	public int getSlicerFontStyle() {
		return slicerFontStyle;
	}

	/**
	 * @param slicerFontStyle
	 */
	public void setSlicerFontStyle(int slicerFontStyle) {
		this.slicerFontStyle = slicerFontStyle;
	}

	/**
	 * @return
	 */
	public int getSlicerPosition() {
		return slicerPosition;
	}

	/**
	 * @param slicerPosition
	 */
	public void setSlicerPosition(int slicerPosition) {
		this.slicerPosition = slicerPosition;
	}

	/**
	 * @return
	 */
	public int getLegendPosition() {
		return legendPosition;
	}

	/**
	 * @param legendPosition
	 */
	public void setLegendPosition(int legendPosition) {
		this.legendPosition = legendPosition;
	}

	/**
	 * @return
	 */
	public String getAxisTickFontName() {
		return axisTickFontName;
	}

	/**
	 * @param axisTickFontName
	 */
	public void setAxisTickFontName(String axisTickFontName) {
		this.axisTickFontName = axisTickFontName;
	}

	/**
	 * @return
	 */
	public int getAxisTickFontSize() {
		return axisTickFontSize;
	}

	/**
	 * @param axisTickFontSize
	 */
	public void setAxisTickFontSize(int axisTickFontSize) {
		this.axisTickFontSize = axisTickFontSize;
	}

	/**
	 * @return
	 */
	public int getAxisTickFontStyle() {
		return axisTickFontStyle;
	}

	/**
	 * @param axisTickFontStyle
	 */
	public void setAxisTickFontStyle(int axisTickFontStyle) {
		this.axisTickFontStyle = axisTickFontStyle;
	}
      /**
       * @return Returns the tickLabelRotate.
       */
      public int getTickLabelRotate() {
        return tickLabelRotate;
      }
      /**
       * @param tickLabelRotate The tickLabelRotate to set.
       */
      public void setTickLabelRotate(int tickLabelRotate) {
        this.tickLabelRotate = tickLabelRotate;
      }
	/**
	 * @return
	 */
	public boolean isShowSlicer() {
		return showSlicer;
	}

	/**
	 * @param showSlicer
	 */
	public void setShowSlicer(boolean showSlicer) {
		this.showSlicer = showSlicer;
	}

        /**
	 * @return
	 */
	public String getFilename() {
		return filename;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -