mxgraphが画像をエクスポートする中国語の文字化とイメージノードが表示できない問題を解決します。


1、前に書いてください。mxgraphのjarカバンはソースコードがあります。mxgraph\java\srcにあります。
2、私が直した部分:
\src\com\mxgraph\util\mxUtils.java
のメソッドpublic static BufferedImage loadImage(String url)

/**
	 * Loads an image from the local filesystem, a data URI or any other URL.
*              ,     graph xml  ,     src             !
	 */
	public static BufferedImage loadImage(String url)
	{
		BufferedImage img = null;
		if (url != null)
		{
			// Parses data URIs of the form data:image/format;base64,xxx
			if (url.startsWith("data:image/"))
			{
				try
				{
					int comma = url.indexOf(',');
					byte[] data = mxBase64.decode(url.substring(comma + 1));
					ByteArrayInputStream is = new ByteArrayInputStream(data);
					img = ImageIO.read(is);
				}
				catch (Exception e1)
				{
					// ignore
				}
			}else if(url.startsWith("http://")){
				URL realURL = null;

				try
				{
					realURL = new URL(url);
					
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
				if (realURL != null)
				{
					try
					{
						img = ImageIO.read(realURL);
					}
					catch (Exception e1)
					{
						// ignore
					}
				}
			}else
			{//        deal with the local image sourse
				File imageFile = null;

				try
				{
					imageFile = new File(url);
					System.out.println(imageFile.getAbsoluteFile());
					
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
				if (imageFile != null)
				{
					try
					{
						img = ImageIO.read(imageFile);
					}
					catch (Exception e1)
					{
						// ignore
					}
				}
			}
		}

		return img;
	}


src\com\mxgraph\canvas\mxGraphcs Canvas 2 D.java
方法public void textを修正しました。(double x、double y、double w、double h、String str、
String align,String valign,bootlean vertical)

/**
	 * Draws the given text.
	 */
	public void text(double x, double y, double w, double h, String str,
			String align, String valign, boolean vertical)
	{
		if (!state.fontColorValue.equals(mxConstants.NONE))
		{
			x = state.dx + x * state.scale;
			y = state.dy + y * state.scale;
			w *= state.scale;
			h *= state.scale;
			Graphics2D g2 = createTextGraphics(x, y, w, h, vertical);
			Font font = new Font("  ", Font.BOLD, 12);//                  ,    activiti    png          !
		    g2.setFont(font);
			FontMetrics fm = g2.getFontMetrics();
			String[] lines = str.split("
"); y = getVerticalTextPosition(x, y, w, h, align, valign, vertical, fm, lines); x = getHorizontalTextPosition(x, y, w, h, align, valign, vertical, fm, lines); for (int i = 0; i < lines.length; i++) { double dx = 0; if (align != null) { if (align.equals(mxConstants.ALIGN_CENTER)) { int sw = fm.stringWidth(lines[i]); dx = (w - sw) / 2; } else if (align.equals(mxConstants.ALIGN_RIGHT)) { int sw = fm.stringWidth(lines[i]); dx = w - sw; } } g2.drawString(lines[i], (int) Math.round(x + dx), (int) Math.round(y)); y += fm.getHeight() + mxConstants.LINESPACING; } } }
3.包装方法
この二つのファイルをコンパイルして作成したクラスファイルをmxgraphh-coree.jarの同名のクラスファイルに置き換えればいいです。
特に注意してください。あなたの工程にmxgraph-corer.jarというカバンを追加するだけで、他のmxgrapphのカバンは追加しなくてもいいです。重複します
******の最も重要な分割線
愛が期限切れの缶詰なら、賞味期限は変わらないと言っています。賞味期限はそこです。増量しないと減らないです。でも、私はどんなに望んでいますか?always have always will…