Java 类org.eclipse.swt.graphics.Drawable 实例源码

项目:vTM-eclipse    文件:TrafficScriptInfoPresenter.java   
public String updatePresentation( Drawable drawable, String hoverInfo,
   TextPresentation presentation, int maxWidth, int maxHeight )
{
   ZDebug.print( 5, "updatePresentation( ", drawable, ", ", hoverInfo, ", ", presentation, ", ", maxWidth, ", ", maxHeight, " )" );

   HTMLFormat html = new HTMLFormat();
   html.format( hoverInfo );

   for( StyleRange style : html.getStyleList() ) {
      presentation.addStyleRange( style );
   }

   if( drawable instanceof StyledText ) {
      StyledText styled = (StyledText) drawable;
      styled.setWordWrap( html.isWordWrap() );
      if( !html.isWordWrap() ) {
         SWTUtil.fontPreference( styled, ExternalPreference.FONT_EDITOR_TEXT );
      }
   }

   return html.getBuffer();
}
项目:OpenSPIFe    文件:TooltipShellBuilder.java   
private static String getWrappedString(Drawable drawable, int width, String string) {
    GC gc = new GC(drawable);
    StringBuilder sb = new StringBuilder();
    String[] tokens = string.split(SPACE);
    StringBuilder lineBuilder = new StringBuilder();
    for (String token : tokens) {
        if (gc.textExtent(lineBuilder.toString() + token).x > width) {
            sb.append(lineBuilder.append(STRING_STRINGIFIER.getSystemLineSeparator()).toString());
            lineBuilder = new StringBuilder();
        }
        lineBuilder.append(token).append(SPACE);
    }
    sb.append(lineBuilder.toString());
    gc.dispose();
    return sb.toString();
}
项目:PDFReporter-Studio    文件:UIUtil.java   
public static int getCharWidth(Drawable control) {
    GC gc = new GC(control);
    FontMetrics fm = gc.getFontMetrics();
    int w = fm.getAverageCharWidth();
    gc.dispose();
    return w;
}
项目:PDFReporter-Studio    文件:UIUtil.java   
public static int getCharHeight(Drawable control) {
    GC gc = new GC(control);
    FontMetrics fm = gc.getFontMetrics();
    int h = fm.getHeight();
    gc.dispose();
    return h;
}
项目:chromedevtools    文件:PluginUtil.java   
/**
 * @param font or null to use default font
 */
public static FontMetrics getFontMetrics(Drawable drawable, Font font) {
  GC gc = new GC(drawable);
  try {
    if (font != null) {
      gc.setFont(font);
    }
    return gc.getFontMetrics();
  } finally {
    gc.dispose();
  }
}
项目:birt    文件:ReportGraphicsViewPainter.java   
public void paint( Drawable drawable, Device device, Rectangle region )
{
    ReportPrintGraphicalViewerOperation op = new ReportPrintGraphicalViewerOperation( viewer,
            drawable,
            device,
            new org.eclipse.draw2d.geometry.Rectangle( region ) );
    if (model instanceof ReportDesignHandle)
    {
        op.setOrientation( ((ReportDesignHandle)model).getBidiOrientation( ) );
    }

    op.run( "paint" ); //$NON-NLS-1$

}
项目:birt    文件:ReportPrintGraphicalViewerOperation.java   
public ReportPrintGraphicalViewerOperation( GraphicalViewer g,
        Drawable drawable, Device device, Rectangle region )
{
    this.device = device;
    this.region = region;
    this.drawable = drawable;
    this.viewer = g;

    LayerManager lm = (LayerManager) viewer.getEditPartRegistry( )
            .get( LayerManager.ID );
    IFigure f = lm.getLayer( LayerConstants.PRINTABLE_LAYERS );

    this.printSource = f;
}
项目:idecore    文件:HTMLTextPresenter.java   
@Override
   public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {
    return updatePresentation((Drawable)display, hoverInfo, presentation, maxWidth, maxHeight);
}
项目:idecore    文件:HTMLTextPresenter.java   
@Override
   public String updatePresentation(Drawable drawable, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {

    if (hoverInfo == null)
        return null;

    GC gc= new GC(drawable);
    try {

        StringBuffer buffer= new StringBuffer();
        int maxNumberOfLines= Math.round(maxHeight / gc.getFontMetrics().getHeight());

        fCounter= 0;
        LineBreakingReader reader= new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth);

        boolean lastLineFormatted= false;
        String lastLineIndent= null;

        String line=reader.readLine();
        boolean lineFormatted= reader.isFormattedLine();
        boolean firstLineProcessed= false;

        while (line != null) {

            if (fEnforceUpperLineLimit && maxNumberOfLines <= 0)
                break;

            if (firstLineProcessed) {
                if (!lastLineFormatted)
                    append(buffer, LINE_DELIM, null);
                else {
                    append(buffer, LINE_DELIM, presentation);
                    if (lastLineIndent != null)
                        append(buffer, lastLineIndent, presentation);
                }
            }

            append(buffer, line, null);
            firstLineProcessed= true;

            lastLineFormatted= lineFormatted;
            if (!lineFormatted)
                lastLineIndent= null;
            else if (lastLineIndent == null)
                lastLineIndent= getIndent(line);

            line= reader.readLine();
            lineFormatted= reader.isFormattedLine();

            maxNumberOfLines--;
        }

        if (line != null) {
            append(buffer, LINE_DELIM, lineFormatted ? presentation : null);
            append(buffer, HTMLMessages.getString("HTMLTextPresenter.ellipse"), presentation); //$NON-NLS-1$
        }

        return trim(buffer, presentation);

    } catch (IOException e) {
        return null;

    } finally {
        gc.dispose();
    }
}
项目:Pydev    文件:AbstractInformationPresenter.java   
/**
 * This method shouldn't really be used, but if it is, just forward it to the new method.
 */
@Override
public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth,
        int maxHeight) {
    return updatePresentation((Drawable) display, hoverInfo, presentation, maxWidth, maxHeight);
}
项目:birt    文件:ReportPrintGraphicalViewerOperation.java   
/**
 * Gets the composite.
 * 
 * @return
 */
protected Drawable getDrawable( )
{
    return drawable;
}