當前位置: 首頁>>代碼示例>>Java>>正文


Java CellRendererPane.paintComponent方法代碼示例

本文整理匯總了Java中javax.swing.CellRendererPane.paintComponent方法的典型用法代碼示例。如果您正苦於以下問題:Java CellRendererPane.paintComponent方法的具體用法?Java CellRendererPane.paintComponent怎麽用?Java CellRendererPane.paintComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.CellRendererPane的用法示例。


在下文中一共展示了CellRendererPane.paintComponent方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getScreenshot

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
private BufferedImage getScreenshot(Container panel) {
	Dimension size = new Dimension((int) panel.getPreferredSize().getWidth()+50, (int) panel.getPreferredSize().getHeight()+10);
	panel.setSize(size);

	this.layoutComponent(panel);

	BufferedImage img = new BufferedImage(panel.getWidth(), panel.getHeight(), BufferedImage.TYPE_INT_RGB);

	//Remove buttons panel
	panel.getComponent(2).setVisible(false);

	CellRendererPane crp = new CellRendererPane();
	crp.add(panel);
	crp.paintComponent(img.createGraphics(), panel, crp, panel.getBounds());

	//Re-add buttons panel
	panel.getComponent(2).setVisible(true);

	return img;
}
 
開發者ID:Shadorc,項目名稱:Twitter-Stalker-V.2,代碼行數:21,代碼來源:Share.java

示例2: paintTable

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
protected void paintTable(Graphics g) {
	treeTableCellRenderer.prepareForTable(g);
	Graphics cg = g.create(0, 0, treeTable.getWidth(), treeTable.getHeight());
	try {
		table.paint(cg);
	} finally {
		cg.dispose();
	}
	
	// JTable doesn't paint anything for the editing cell,
	// so painting the background color is placed here
	if (table.isEditing()) {
		int col = table.getEditingColumn();
		int row = table.getEditingRow();
		boolean sel = treeTableCellRenderer.isSelected(
				tree.isRowSelected(row) && table.isColumnSelected(col));
		TreeTableCellRenderer r = treeTable.getCellRenderer(row, col);
		Component c = r.getTreeTableCellRendererComponent(
					treeTable, null, sel, false, row, col);
		// TODO, create CellRendererPane for TreeTable, for use by the focus renderer too.
		CellRendererPane rp = (CellRendererPane)table.getComponent(0);
		Rectangle cell = table.getCellRect(row, col, true);
		rp.paintComponent(g, c, table, cell.x, cell.y, cell.width, cell.height, true);
		rp.removeAll();
	}
}
 
開發者ID:Sciss,項目名稱:TreeTable,代碼行數:27,代碼來源:BasicTreeTableUI.java

示例3: run

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
@Override
public void run() {

    Dimension size = new Dimension(575, 275);
    for (String lookAndFeelClassName : LOOK_AND_FEELS) {
        ExampleRunner.useLookAndFeel(lookAndFeelClassName);
        FontChooser fontChooser = new FontChooser(new Font("Helvetica", Font.PLAIN, 24));
        fontChooser.setBorder(new EmptyBorder(10, 10, 10, 10));
        fontChooser.setSize(size);
        layoutComponent(fontChooser);

        CellRendererPane rendererPane = new CellRendererPane();
        rendererPane.add(fontChooser);

        BufferedImage image = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_ARGB);
        Graphics graphics = image.createGraphics();

        rendererPane.paintComponent(graphics, fontChooser, rendererPane, fontChooser.getBounds());

        String pathname = createFileName(lookAndFeelClassName);
        try {
            ImageIO.write(image, "png", new File(pathname));
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
 
開發者ID:dheid,項目名稱:fontchooser,代碼行數:28,代碼來源:ScreenshotMaker.java

示例4: paintShape

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text,
		mxCellState state, Map<String, Object> style)
{
	mxLightweightLabel textRenderer = mxLightweightLabel
			.getSharedInstance();
	CellRendererPane rendererPane = canvas.getRendererPane();
	Rectangle rect = state.getLabelBounds().getRectangle();
	Graphics2D g = canvas.getGraphics();

	if (textRenderer != null
			&& rendererPane != null
			&& (g.getClipBounds() == null || g.getClipBounds().intersects(
					rect)))
	{
		double scale = canvas.getScale();
		int x = rect.x;
		int y = rect.y;
		int w = rect.width;
		int h = rect.height;

		if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true))
		{
			g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
			g.translate(w / 2 - h / 2, h / 2 - w / 2);

			int tmp = w;
			w = h;
			h = tmp;
		}

		// Replaces the linefeeds with BR tags
		if (isReplaceHtmlLinefeeds())
		{
			text = text.replaceAll("\n", "<br>");
		}

		// Renders the scaled text
		textRenderer.setText(createHtmlDocument(style, text,
				(int) Math.round(w / state.getView().getScale()),
				(int) Math.round(h / state.getView().getScale())));
		textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
		g.scale(scale, scale);
		rendererPane.paintComponent(g, textRenderer, rendererPane,
				(int) (x / scale) + mxConstants.LABEL_INSET,
				(int) (y / scale) + mxConstants.LABEL_INSET,
				(int) (w / scale), (int) (h / scale), true);
	}
}
 
開發者ID:GDSRS,項目名稱:TrabalhoFinalEDA2,代碼行數:52,代碼來源:mxHtmlTextShape.java

示例5: paintShape

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text, mxCellState state,
    Map<String, Object> style) {
  mxLightweightLabel textRenderer = mxLightweightLabel.getSharedInstance();
  CellRendererPane rendererPane = canvas.getRendererPane();
  Rectangle rect = state.getLabelBounds().getRectangle();
  Graphics2D g = canvas.getGraphics();

  if (textRenderer != null && rendererPane != null
      && (g.getClipBounds() == null || g.getClipBounds().intersects(rect))) {
    double scale = canvas.getScale();
    int x = rect.x;
    int y = rect.y;
    int w = rect.width;
    int h = rect.height;

    if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true)) {
      g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
      g.translate(w / 2 - h / 2, h / 2 - w / 2);

      int tmp = w;
      w = h;
      h = tmp;
    }

    // Replaces the linefeeds with BR tags
    if (isReplaceHtmlLinefeeds()) {
      text = text.replaceAll("\n", "<br>");
    }

    // Renders the scaled text
    textRenderer
        .setText(createHtmlDocument(style, text, (int) Math.round(w / state.getView().getScale()),
            (int) Math.round(h / state.getView().getScale())));
    textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
    g.scale(scale, scale);
    rendererPane.paintComponent(g, textRenderer, rendererPane,
        (int) (x / scale) + mxConstants.LABEL_INSET, (int) (y / scale) + mxConstants.LABEL_INSET,
        (int) (w / scale), (int) (h / scale), true);
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:44,代碼來源:mxHtmlTextShape.java

示例6: paintShape

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
@Override
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text,
		mxCellState state, Map<String, Object> style)
{
	mxLightweightLabel textRenderer = mxLightweightLabel
			.getSharedInstance();
	CellRendererPane rendererPane = canvas.getRendererPane();
	Rectangle rect = state.getLabelBounds().getRectangle();
	Graphics2D g = canvas.getGraphics();

	if (textRenderer != null
			&& rendererPane != null
			&& (g.getClipBounds() == null || g.getClipBounds().intersects(
					rect)))
	{
		double scale = canvas.getScale();
		int x = rect.x;
		int y = rect.y;
		int w = rect.width;
		int h = rect.height;

		boolean horizontal = mxUtils.isTrue(style,
				mxConstants.STYLE_HORIZONTAL, true);
		String degree;

		     degree = (String) style.get(MXConstants.FONT_ROTATION_DEGREE);
		     if (degree != null) {
		        if (degree.equals("90")) {
		            g.rotate(Math.PI / 2, x + w / 2, y + h / 2);
		            g.translate(w / 2 - h / 2, h / 2 - w / 2);
		        } else if (degree.equals("270")) {
		            g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
		            g.translate(w / 2 - h / 2, h / 2 - w / 2);
		        }

		        if (degree.equals("180")) {
		            g.rotate(Math.PI, x + w / 2, y + h / 2);
		        } else if (degree.equals("360")) {
		            g.rotate(Math.PI * 2, x + w / 2, y + h / 2);
		        }
		    }
		 

		// Replaces the linefeeds with BR tags
		if (isReplaceHtmlLinefeeds())
		{
			text = text.replaceAll("\n", "<br>");
		}

		// Renders the scaled text
		textRenderer.setText(createHtmlDoc(style, text, scale, 0, null));
		textRenderer.setFont(Utils.getFont(style, canvas.getScale()));
		g.scale(scale, scale);
		rendererPane.paintComponent(g, textRenderer, rendererPane,
				(int) (x / scale) + mxConstants.LABEL_INSET,
				(int) (y / scale) + mxConstants.LABEL_INSET,
				(int) (w / scale), (int) (h / scale), true);
	}
}
 
開發者ID:iig-uni-freiburg,項目名稱:WOLFGANG,代碼行數:63,代碼來源:HtmlTextShape.java

示例7: draw

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
public void draw(Component c, CellRendererPane rendererPane, 
		int x, int y, int w, int h, boolean shouldValidate) {
	rendererPane.paintComponent(delegate, c, c.getParent(), x, y, w, h, shouldValidate);
}
 
開發者ID:SiLeBAT,項目名稱:BfROpenLab,代碼行數:5,代碼來源:GraphicsDecorator.java

示例8: paintShape

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text,
		mxCellState state, Map<String, Object> style)
{
	mxLightweightLabel textRenderer = mxLightweightLabel
			.getSharedInstance();
	CellRendererPane rendererPane = canvas.getRendererPane();
	Rectangle rect = state.getLabelBounds().getRectangle();
	Graphics2D g = canvas.getGraphics();

	if (textRenderer != null
			&& rendererPane != null
			&& (g.getClipBounds() == null || g.getClipBounds().intersects(
					rect)))
	{
		double scale = canvas.getScale();
		int x = rect.x;
		int y = rect.y;
		int w = rect.width;
		int h = rect.height;

		if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true))
		{
			g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
			g.translate(w / 2 - h / 2, h / 2 - w / 2);

			int tmp = w;
			w = h;
			h = tmp;
		}

		// Replaces the linefeeds with BR tags
		if (isReplaceHtmlLinefeeds())
		{
			text = text.replaceAll("\n", "<br>");
		}

		// Renders the scaled text
		textRenderer.setText(mxUtils.createHtmlDocument(style, text));
		textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
		g.scale(scale, scale);
		rendererPane.paintComponent(g, textRenderer, rendererPane,
				(int) (x / scale) + mxConstants.LABEL_INSET,
				(int) (y / scale) + mxConstants.LABEL_INSET,
				(int) (w / scale), (int) (h / scale), true);
	}
}
 
開發者ID:alect,項目名稱:Puzzledice,代碼行數:50,代碼來源:mxHtmlTextShape.java

示例9: paintShape

import javax.swing.CellRendererPane; //導入方法依賴的package包/類
/**
 * 
 */
public void paintShape(mxGraphics2DCanvas canvas, String text,
		mxCellState state, Map<String, Object> style)
{
	mxLightweightLabel textRenderer = mxLightweightLabel
			.getSharedInstance();
	CellRendererPane rendererPane = canvas.getRendererPane();
	Rectangle rect = state.getLabelBounds().getRectangle();
	Graphics2D g = canvas.getGraphics();

	if (textRenderer != null
			&& rendererPane != null
			&& (g.getClipBounds() == null || g.getClipBounds().intersects(
					rect)))
	{
		double scale = canvas.getScale();
		int x = rect.x;
		int y = rect.y;
		int w = rect.width;
		int h = rect.height;

		if (!mxUtils.isTrue(style, mxConstants.STYLE_HORIZONTAL, true))
		{
			g.rotate(-Math.PI / 2, x + w / 2, y + h / 2);
			g.translate(w / 2 - h / 2, h / 2 - w / 2);

			int tmp = w;
			w = h;
			h = tmp;
		}

		// Replaces the linefeeds with BR tags
		if (isReplaceHtmlLinefeeds())
		{
			text = text.replaceAll("\n", "<br>");
		}

		// Renders the scaled text
		textRenderer.setText(createHtmlDocument(style, text));
		textRenderer.setFont(mxUtils.getFont(style, canvas.getScale()));
		g.scale(scale, scale);
		rendererPane.paintComponent(g, textRenderer, rendererPane,
				(int) (x / scale) + mxConstants.LABEL_INSET,
				(int) (y / scale) + mxConstants.LABEL_INSET,
				(int) (w / scale), (int) (h / scale), true);
	}
}
 
開發者ID:luartmg,項目名稱:WMA,代碼行數:50,代碼來源:mxHtmlTextShape.java


注:本文中的javax.swing.CellRendererPane.paintComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。