src/main/java/com/mxgraph/canvas/mxGraphicsCanvas2D.java
protected String createHtmlDocument(String text, String align,
			String valign, int w, int h, boolean wrap, String overflow,
			boolean clip)
	{
		StringBuffer css = new StringBuffer();
		css.append("display:inline;");
		css.append("font-family:" + state.fontFamily + ";");
		css.append("font-size:" + Math.round(state.fontSize) + HTML_UNIT
				+ ";");
		css.append("color:" + state.fontColorValue + ";");
		// KNOWN: Line-height ignored in JLabel
		css.append("line-height:"
				+ ((mxConstants.ABSOLUTE_LINE_HEIGHT)
						? Math.round(state.fontSize * mxConstants.LINE_HEIGHT)
								+ " " + HTML_UNIT
						: mxConstants.LINE_HEIGHT)
				+ ";");

		boolean setWidth = false;

		if ((state.fontStyle & mxConstants.FONT_BOLD) == mxConstants.FONT_BOLD)
		{
			css.append("font-weight:bold;");
		}

		if ((state.fontStyle
				& mxConstants.FONT_ITALIC) == mxConstants.FONT_ITALIC)
		{
			css.append("font-style:italic;");
		}

		String txtDecor = "";
		
		if ((state.fontStyle
				& mxConstants.FONT_UNDERLINE) == mxConstants.FONT_UNDERLINE)
	    {
			txtDecor = "underline";
	    }
	    
	    if ((state.fontStyle
				& mxConstants.FONT_STRIKETHROUGH) == mxConstants.FONT_STRIKETHROUGH)
	    {
	    	txtDecor += " line-through";
	    }

	    if (txtDecor.length() > 0)
	    {
	    	css.append("text-decoration: " + txtDecor + ";");
	    }
	    
		if (align != null)
		{
			if (align.equals(mxConstants.ALIGN_CENTER))
			{
				css.append("text-align:center;");
			}
			else if (align.equals(mxConstants.ALIGN_RIGHT))
			{
				css.append("text-align:right;");
			}
		}

		if (state.fontBackgroundColorValue != null)
		{
			css.append(
					"background-color:" + state.fontBackgroundColorValue + ";");
		}

		// KNOWN: Border ignored in JLabel
		if (state.fontBorderColorValue != null)
		{
			css.append("border:1pt solid " + state.fontBorderColorValue + ";");
		}

		// KNOWN: max-width/-height ignored in JLabel
		if (clip)
		{
			css.append("overflow:hidden;");
			setWidth = true;
		}
		else if (overflow != null)
		{
			if (overflow.equals("fill"))
			{
				css.append("height:" + Math.round(h) + HTML_UNIT + ";");
				setWidth = true;
			}
			else if (overflow.equals("width"))
			{
				setWidth = true;

				if (h > 0)
				{
					css.append(
							"height:" + Math.round(h) + HTML_UNIT + ";");
				}
			}
		}

		if (wrap)
		{
			if (!clip)
			{
				// NOTE: Max-width not available in Java
				setWidth = true;
			}

			css.append("white-space:normal;");
		}
		else
		{
			css.append("white-space:nowrap;");
		}

		if (setWidth && w > 0)
		{
			css.append("width:" + Math.round(w) + HTML_UNIT + ";");
		}

		return createHtmlDocument(text, css.toString());
	}
/**
	 * Creates a HTML document around the given markup.
	 */
Creates a HTML document around the given markup.
Creates a HTML document around the given markup .
protected String createHtmlDocument(String text, String align,
			String valign, int w, int h, boolean wrap, String overflow,
			boolean clip)
	{
		StringBuffer css = new StringBuffer();
		css.append("display:inline;");
		css.append("font-family:" + state.fontFamily + ";");
		css.append("font-size:" + Math.round(state.fontSize) + HTML_UNIT
				+ ";");
		css.append("color:" + state.fontColorValue + ";");
		css.append("line-height:"
				+ ((mxConstants.ABSOLUTE_LINE_HEIGHT)
						? Math.round(state.fontSize * mxConstants.LINE_HEIGHT)
								+ " " + HTML_UNIT
						: mxConstants.LINE_HEIGHT)
				+ ";");
		boolean setWidth = false;
		if ((state.fontStyle & mxConstants.FONT_BOLD) == mxConstants.FONT_BOLD)
		{
			css.append("font-weight:bold;");
		}
		if ((state.fontStyle
				& mxConstants.FONT_ITALIC) == mxConstants.FONT_ITALIC)
		{
			css.append("font-style:italic;");
		}
		String txtDecor = "";
		if ((state.fontStyle
				& mxConstants.FONT_UNDERLINE) == mxConstants.FONT_UNDERLINE)
	    {
			txtDecor = "underline";
	    }
	    if ((state.fontStyle
				& mxConstants.FONT_STRIKETHROUGH) == mxConstants.FONT_STRIKETHROUGH)
	    {
	    	txtDecor += " line-through";
	    }
	    if (txtDecor.length() > 0)
	    {
	    	css.append("text-decoration: " + txtDecor + ";");
	    }
		if (align != null)
		{
			if (align.equals(mxConstants.ALIGN_CENTER))
			{
				css.append("text-align:center;");
			}
			else if (align.equals(mxConstants.ALIGN_RIGHT))
			{
				css.append("text-align:right;");
			}
		}
		if (state.fontBackgroundColorValue != null)
		{
			css.append(
					"background-color:" + state.fontBackgroundColorValue + ";");
		}
		if (state.fontBorderColorValue != null)
		{
			css.append("border:1pt solid " + state.fontBorderColorValue + ";");
		}
		if (clip)
		{
			css.append("overflow:hidden;");
			setWidth = true;
		}
		else if (overflow != null)
		{
			if (overflow.equals("fill"))
			{
				css.append("height:" + Math.round(h) + HTML_UNIT + ";");
				setWidth = true;
			}
			else if (overflow.equals("width"))
			{
				setWidth = true;
				if (h > 0)
				{
					css.append(
							"height:" + Math.round(h) + HTML_UNIT + ";");
				}
			}
		}
		if (wrap)
		{
			if (!clip)
			{
				setWidth = true;
			}
			css.append("white-space:normal;");
		}
		else
		{
			css.append("white-space:nowrap;");
		}
		if (setWidth && w > 0)
		{
			css.append("width:" + Math.round(w) + HTML_UNIT + ";");
		}
		return createHtmlDocument(text, css.toString());
	}
protected String createHtmlDocument ( String text , String align , String valign , int w , int h , boolean wrap , String overflow , boolean clip ) { StringBuffer css = new StringBuffer ( ) ; css . append ( "display:inline;" ) ; css . append ( "font-family:" + state . fontFamily + ";" ) ; css . append ( "font-size:" + Math . round ( state . fontSize ) + HTML_UNIT + ";" ) ; css . append ( "color:" + state . fontColorValue + ";" ) ; css . append ( "line-height:" + ( ( mxConstants . ABSOLUTE_LINE_HEIGHT ) ? Math . round ( state . fontSize * mxConstants . LINE_HEIGHT ) + " " + HTML_UNIT : mxConstants . LINE_HEIGHT ) + ";" ) ; boolean setWidth = false ; if ( ( state . fontStyle & mxConstants . FONT_BOLD ) == mxConstants . FONT_BOLD ) { css . append ( "font-weight:bold;" ) ; } if ( ( state . fontStyle & mxConstants . FONT_ITALIC ) == mxConstants . FONT_ITALIC ) { css . append ( "font-style:italic;" ) ; } String txtDecor = "" ; if ( ( state . fontStyle & mxConstants . FONT_UNDERLINE ) == mxConstants . FONT_UNDERLINE ) { txtDecor = "underline" ; } if ( ( state . fontStyle & mxConstants . FONT_STRIKETHROUGH ) == mxConstants . FONT_STRIKETHROUGH ) { txtDecor += " line-through" ; } if ( txtDecor . length ( ) > 0 ) { css . append ( "text-decoration: " + txtDecor + ";" ) ; } if ( align != null ) { if ( align . equals ( mxConstants . ALIGN_CENTER ) ) { css . append ( "text-align:center;" ) ; } else if ( align . equals ( mxConstants . ALIGN_RIGHT ) ) { css . append ( "text-align:right;" ) ; } } if ( state . fontBackgroundColorValue != null ) { css . append ( "background-color:" + state . fontBackgroundColorValue + ";" ) ; } if ( state . fontBorderColorValue != null ) { css . append ( "border:1pt solid " + state . fontBorderColorValue + ";" ) ; } if ( clip ) { css . append ( "overflow:hidden;" ) ; setWidth = true ; } else if ( overflow != null ) { if ( overflow . equals ( "fill" ) ) { css . append ( "height:" + Math . round ( h ) + HTML_UNIT + ";" ) ; setWidth = true ; } else if ( overflow . equals ( "width" ) ) { setWidth = true ; if ( h > 0 ) { css . append ( "height:" + Math . round ( h ) + HTML_UNIT + ";" ) ; } } } if ( wrap ) { if ( ! clip ) { setWidth = true ; } css . append ( "white-space:normal;" ) ; } else { css . append ( "white-space:nowrap;" ) ; } if ( setWidth && w > 0 ) { css . append ( "width:" + Math . round ( w ) + HTML_UNIT + ";" ) ; } return createHtmlDocument ( text , css . toString ( ) ) ; }
Creates a HTML document around the given markup.
Creates a HTML document around the given markup .
// KNOWN: Line-height ignored in JLabel // KNOWN: Border ignored in JLabel // KNOWN: max-width/-height ignored in JLabel // NOTE: Max-width not available in Java