org-netbeans-modules-print

16:40:04.997 INFO  jd.cli.Main - Decompiling org-netbeans-modules-print.jar
package org.netbeans.api.print;

import javax.swing.Action;
import javax.swing.JComponent;
import org.netbeans.modules.print.action.PrintAction;
import org.netbeans.spi.print.PrintProvider;

public final class PrintManager
{
  public static final String PRINT_NAME = "print.name";
  public static final String PRINT_ORDER = "print.order";
  public static final String PRINT_SIZE = "print.size";
  public static final String PRINT_PRINTABLE = "print.printable";
  
  public static Action printAction(JComponent paramJComponent)
  {
    return new PrintAction(paramJComponent);
  }
  
  public static Action printAction(PrintProvider[] paramArrayOfPrintProvider)
  {
    return new PrintAction(paramArrayOfPrintProvider);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.api.print.PrintManager
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.action;

import org.netbeans.modules.print.util.Config;
import org.netbeans.modules.print.util.UI;
import org.openide.util.HelpCtx;
import org.openide.util.actions.CallableSystemAction;

public final class PageSetupAction
  extends CallableSystemAction
{
  public synchronized void performAction()
  {
    Config.getDefault().showPageSetup();
  }
  
  protected boolean asynchronous()
  {
    return false;
  }
  
  public String getName()
  {
    return UI.i18n(PageSetupAction.class, "LBL_PageSetup_Action");
  }
  
  public HelpCtx getHelpCtx()
  {
    return HelpCtx.DEFAULT_HELP;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.action.PageSetupAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.action;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JComponent;
import org.netbeans.modules.print.provider.ComponentProvider;
import org.netbeans.modules.print.provider.EditorProvider;
import org.netbeans.modules.print.provider.TextProvider;
import org.netbeans.modules.print.ui.Preview;
import org.netbeans.modules.print.util.Config;
import org.netbeans.modules.print.util.UI;
import org.netbeans.modules.print.util.UI.IconAction;
import org.netbeans.spi.print.PrintProvider;
import org.openide.cookies.EditorCookie;
import org.openide.cookies.PrintCookie;
import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.windows.TopComponent;

public final class PrintAction
  extends UI.IconAction
{
  private boolean myEnabled;
  private PrintProvider[] myProviders;
  
  public PrintAction()
  {
    this("MNU_Print_Action", "TLT_Print_Action", null, false, null);
  }
  
  public PrintAction(PrintProvider[] paramArrayOfPrintProvider)
  {
    this(null, "ACT_Print_Action", "print", true, paramArrayOfPrintProvider);
  }
  
  public PrintAction(JComponent paramJComponent)
  {
    this((PrintProvider[])null);
    myProviders = getComponentProviders(paramJComponent);
  }
  
  private PrintAction(String paramString1, String paramString2, String paramString3, boolean paramBoolean, PrintProvider[] paramArrayOfPrintProvider)
  {
    super(UI.i18n(PrintAction.class, paramString1), UI.i18n(PrintAction.class, paramString2), UI.icon(Config.class, paramString3));
    setEnabled(paramBoolean);
    myEnabled = paramBoolean;
    myProviders = paramArrayOfPrintProvider;
  }
  
  public void actionPerformed(ActionEvent paramActionEvent)
  {
    if (myProviders == null) {
      myProviders = getPrintProviders();
    }
    if (myProviders != null)
    {
      Preview.getDefault().print(myProviders, true);
      if (!myEnabled) {
        myProviders = null;
      }
    }
    else
    {
      PrintCookie localPrintCookie = getPrintCookie();
      if (localPrintCookie != null) {
        localPrintCookie.print();
      }
    }
  }
  
  private PrintProvider[] getPrintProviders()
  {
    PrintProvider[] arrayOfPrintProvider = getTopProviders(UI.getActiveTopComponent());
    if (arrayOfPrintProvider != null) {
      return arrayOfPrintProvider;
    }
    return getEditorInputStreamProviders(UI.getSelectedNodes());
  }
  
  private PrintProvider[] getTopProviders(TopComponent paramTopComponent)
  {
    PrintProvider localPrintProvider = getLookupProvider(paramTopComponent);
    if (localPrintProvider != null) {
      return getProviders(localPrintProvider);
    }
    return getComponentProviders(paramTopComponent);
  }
  
  private PrintProvider getLookupProvider(TopComponent paramTopComponent)
  {
    if (paramTopComponent == null) {
      return null;
    }
    return (PrintProvider)paramTopComponent.getLookup().lookup(PrintProvider.class);
  }
  
  private PrintProvider[] getComponentProviders(JComponent paramJComponent)
  {
    if (paramJComponent == null) {
      return null;
    }
    ArrayList localArrayList = new ArrayList();
    findPrintable(paramJComponent, localArrayList);
    if (localArrayList.size() == 0) {
      return null;
    }
    return getProviders(new ComponentProvider(localArrayList, getName(localArrayList, paramJComponent), getDate(paramJComponent)));
  }
  
  private PrintProvider[] getProviders(PrintProvider paramPrintProvider)
  {
    return new PrintProvider[] { paramPrintProvider };
  }
  
  private void findPrintable(Container paramContainer, List<JComponent> paramList)
  {
    if ((paramContainer.isShowing()) && (isPrintable(paramContainer))) {
      paramList.add((JComponent)paramContainer);
    }
    Component[] arrayOfComponent1 = paramContainer.getComponents();
    for (Component localComponent : arrayOfComponent1) {
      if ((localComponent instanceof Container)) {
        findPrintable((Container)localComponent, paramList);
      }
    }
  }
  
  private boolean isPrintable(Container paramContainer)
  {
    return ((paramContainer instanceof JComponent)) && (((JComponent)paramContainer).getClientProperty("print.printable") == Boolean.TRUE);
  }
  
  private String getName(List<JComponent> paramList, JComponent paramJComponent)
  {
    for (JComponent localJComponent : paramList)
    {
      Object localObject = localJComponent.getClientProperty("print.name");
      if ((localObject instanceof String)) {
        return (String)localObject;
      }
    }
    return getName(getData(paramJComponent));
  }
  
  private String getName(DataObject paramDataObject)
  {
    if (paramDataObject == null) {
      return null;
    }
    return paramDataObject.getName();
  }
  
  private Date getDate(JComponent paramJComponent)
  {
    return getDate(getData(paramJComponent));
  }
  
  private Date getDate(DataObject paramDataObject)
  {
    if (paramDataObject == null) {
      return null;
    }
    return paramDataObject.getPrimaryFile().lastModified();
  }
  
  private DataObject getData(JComponent paramJComponent)
  {
    if (!(paramJComponent instanceof TopComponent)) {
      return null;
    }
    return (DataObject)((TopComponent)paramJComponent).getLookup().lookup(DataObject.class);
  }
  
  private PrintProvider[] getEditorInputStreamProviders(Node[] paramArrayOfNode)
  {
    if (paramArrayOfNode == null) {
      return null;
    }
    ArrayList localArrayList = new ArrayList();
    for (Node localNode : paramArrayOfNode)
    {
      PrintProvider localPrintProvider = getEditorInputStreamProvider(localNode);
      if (localPrintProvider != null) {
        localArrayList.add(localPrintProvider);
      }
    }
    if (localArrayList.size() == 0) {
      return null;
    }
    return (PrintProvider[])localArrayList.toArray(new PrintProvider[localArrayList.size()]);
  }
  
  private PrintProvider getEditorInputStreamProvider(Node paramNode)
  {
    String str = getText((InputStream)paramNode.getLookup().lookup(InputStream.class));
    if (str != null) {
      return new TextProvider(str);
    }
    EditorCookie localEditorCookie = (EditorCookie)paramNode.getLookup().lookup(EditorCookie.class);
    if (localEditorCookie == null) {
      return null;
    }
    if (localEditorCookie.getDocument() == null) {
      return null;
    }
    return new EditorProvider(localEditorCookie, getDate(UI.getDataObject(paramNode)));
  }
  
  private String getText(InputStream paramInputStream)
  {
    if (paramInputStream == null) {
      return null;
    }
    try
    {
      paramInputStream.reset();
      int i = paramInputStream.available();
      byte[] arrayOfByte = new byte[i];
      paramInputStream.read(arrayOfByte);
      paramInputStream.close();
      return new String(arrayOfByte);
    }
    catch (IOException localIOException) {}
    return null;
  }
  
  private PrintCookie getPrintCookie()
  {
    Node localNode = UI.getSelectedNode();
    if (localNode == null) {
      return null;
    }
    return (PrintCookie)localNode.getCookie(PrintCookie.class);
  }
  
  public boolean isEnabled()
  {
    if (myEnabled) {
      return true;
    }
    return (getPrintProviders() != null) || (getPrintCookie() != null);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.action.PrintAction
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

final class ComponentDocument$LineTokenizer
{
  private int myPos;
  private int myLength;
  private String myValue;
  private StringBuilder myBuilder;
  
  public ComponentDocument$LineTokenizer(String paramString)
  {
    myValue = paramString;
    myLength = paramString.length();
    myBuilder = new StringBuilder();
  }
  
  public boolean hasMoreTokens()
  {
    return myPos < myLength;
  }
  
  public String nextToken()
  {
    myBuilder.setLength(0);
    String str = "";
    while (myPos < myLength)
    {
      char c = myValue.charAt(myPos);
      myPos += 1;
      if ((c == '\r') || (c == '\n'))
      {
        if ((c != '\r') || (myPos >= myLength) || (myValue.charAt(myPos) != '\n')) {
          break;
        }
        myPos += 1; break;
      }
      myBuilder.append(c);
    }
    return myBuilder.toString();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentDocument.LineTokenizer
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JComponent;
import org.netbeans.modules.print.util.Config;

final class ComponentDocument
  extends JComponent
{
  private int[] myCorrection;
  private int[] myAscent;
  private int[] myDescent;
  private int[] myLeading;
  private int myMinOffset;
  private Font myTextFont;
  private int myWidth;
  private int myHeight;
  private Color myBackgroundColor;
  private Color myTextColor;
  private double myLineSpacing;
  private boolean myWrapLines;
  private boolean myLineNumbers;
  private List<ComponentLine> myLines;
  
  ComponentDocument(String paramString)
  {
    init();
    prepare(paramString);
    perform();
  }
  
  ComponentDocument(AttributedCharacterIterator[] paramArrayOfAttributedCharacterIterator)
  {
    init();
    prepare(paramArrayOfAttributedCharacterIterator);
    perform();
  }
  
  private void init()
  {
    myWrapLines = Config.getDefault().isWrapLines();
    myLineNumbers = Config.getDefault().isLineNumbers();
    myTextColor = Config.getDefault().getTextColor();
    myTextFont = Config.getDefault().getTextFont();
    myBackgroundColor = Config.getDefault().getBackgroundColor();
    myLineSpacing = Config.getDefault().getLineSpacing();
    myLines = new ArrayList();
  }
  
  private void prepare(String paramString)
  {
    LineTokenizer localLineTokenizer = new LineTokenizer(paramString);
    while (localLineTokenizer.hasMoreTokens())
    {
      ComponentLine localComponentLine = new ComponentLine(trimEnded(localLineTokenizer.nextToken()), myTextFont, myTextColor);
      
      myLines.add(localComponentLine);
    }
  }
  
  private void prepare(AttributedCharacterIterator[] paramArrayOfAttributedCharacterIterator)
  {
    for (AttributedCharacterIterator localAttributedCharacterIterator : paramArrayOfAttributedCharacterIterator)
    {
      ComponentLine localComponentLine = new ComponentLine(localAttributedCharacterIterator, myTextFont, myTextColor);
      
      myLines.add(localComponentLine);
    }
  }
  
  private void perform()
  {
    removeEmptyLinesAtTheEnd();
    if (myLineNumbers) {
      prepareLineNumbering();
    }
    calculateOffset();
    if (myWrapLines) {
      prepareWrapLines();
    } else {
      prepareNoWrapLines();
    }
    calculateMetrics();
  }
  
  private void removeEmptyLinesAtTheEnd()
  {
    int i = myLines.size() - 1;
    while (i >= 0)
    {
      ComponentLine localComponentLine = (ComponentLine)myLines.get(i--);
      if (!localComponentLine.isEmpty()) {
        break;
      }
      myLines.remove(localComponentLine);
    }
  }
  
  private String trimEnded(String paramString)
  {
    int i = paramString.length() - 1;
    while ((i >= 0) && (paramString.charAt(i) == ' ')) {
      i--;
    }
    return paramString.substring(0, i + 1);
  }
  
  private void prepareLineNumbering()
  {
    int i = (myLines.size() + "").length();
    int j = 1;
    for (ComponentLine localComponentLine : myLines) {
      localComponentLine.prepend(getNumber(j++, i));
    }
  }
  
  private void prepareNoWrapLines()
  {
    int i = 0;
    for (ComponentLine localComponentLine : myLines)
    {
      int j = localComponentLine.getWidth();
      if (j > i) {
        i = j;
      }
    }
    myWidth = (i + myMinOffset);
  }
  
  private void prepareWrapLines()
  {
    myWidth = Config.getDefault().getPageWidth();
    
    ArrayList localArrayList = new ArrayList();
    for (ComponentLine localComponentLine : myLines) {
      if (localComponentLine.getWidth() + myMinOffset <= myWidth) {
        localArrayList.add(localComponentLine);
      } else {
        addWordWrappedLine(localArrayList, localComponentLine);
      }
    }
    myLines = localArrayList;
  }
  
  private void addWordWrappedLine(List<ComponentLine> paramList, ComponentLine paramComponentLine)
  {
    if (paramComponentLine.getWidth() + myMinOffset <= myWidth)
    {
      paramList.add(paramComponentLine);
      return;
    }
    int i = paramComponentLine.length();
    int j;
    ComponentLine localComponentLine;
    do
    {
      j = paramComponentLine.lastIndexOf(' ', i - 1);
      if (j == -1)
      {
        addCharWrappedLine(paramList, paramComponentLine);
        break;
      }
      i = j;
      localComponentLine = paramComponentLine.substring(0, j);
      checkOffset(localComponentLine);
    } while (localComponentLine.getWidth() + myMinOffset > myWidth);
    if (localComponentLine.isEmpty())
    {
      addCharWrappedLine(paramList, paramComponentLine);
    }
    else
    {
      paramList.add(localComponentLine);
      localComponentLine = paramComponentLine.substring(j + 1);
      checkOffset(localComponentLine);
      addWordWrappedLine(paramList, localComponentLine);
    }
  }
  
  private void addCharWrappedLine(List<ComponentLine> paramList, ComponentLine paramComponentLine)
  {
    if (paramComponentLine.getWidth() + myMinOffset <= myWidth)
    {
      paramList.add(paramComponentLine);
      return;
    }
    int i = paramComponentLine.length();
    while (i >= 0)
    {
      ComponentLine localComponentLine = paramComponentLine.substring(0, i);
      checkOffset(localComponentLine);
      if (localComponentLine.getWidth() + myMinOffset <= myWidth)
      {
        paramList.add(localComponentLine);
        localComponentLine = paramComponentLine.substring(i);
        checkOffset(localComponentLine);
        addCharWrappedLine(paramList, localComponentLine);
        break;
      }
      i--;
    }
  }
  
  private void checkOffset(ComponentLine paramComponentLine)
  {
    int i = -paramComponentLine.getOffset();
    if (i > myMinOffset) {
      myMinOffset = i;
    }
  }
  
  private void calculateOffset()
  {
    myMinOffset = 0;
    for (ComponentLine localComponentLine : myLines) {
      checkOffset(localComponentLine);
    }
  }
  
  private void calculateMetrics()
  {
    myHeight = 0;
    
    int i = myLines.size();
    myAscent = new int[i];
    myDescent = new int[i];
    myLeading = new int[i];
    myCorrection = new int[i];
    
    int j = Config.getDefault().getPageHeight();
    int k = j;
    for (int n = 0; n < i; n++)
    {
      ComponentLine localComponentLine = (ComponentLine)myLines.get(n);
      
      myAscent[n] = ((int)Math.round(localComponentLine.getAscent() * myLineSpacing));
      myDescent[n] = localComponentLine.getDescent();
      myCorrection[n] = 0;
      int m = myHeight;
      
      myHeight += myAscent[n] + myDescent[n];
      if ((myHeight > k) && (m < k))
      {
        myCorrection[n] = (k - m);
        myHeight += myCorrection[n];
        k += j;
      }
      if (n != i - 1)
      {
        myLeading[n] = localComponentLine.getLeading();
        myHeight += myLeading[n];
      }
    }
  }
  
  public int getWidth()
  {
    return myWidth;
  }
  
  public int getHeight()
  {
    return myHeight;
  }
  
  protected void paintComponent(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = Config.getDefault().getGraphics(paramGraphics);
    
    localGraphics2D.setColor(myBackgroundColor);
    localGraphics2D.fillRect(0, 0, myWidth, myHeight);
    
    int i = 0;
    for (int j = 0; j < myLines.size(); j++)
    {
      ComponentLine localComponentLine = (ComponentLine)myLines.get(j);
      i += myCorrection[j] + myAscent[j];
      localComponentLine.draw(localGraphics2D, myMinOffset, i);
      
      i += myDescent[j] + myLeading[j];
    }
  }
  
  private String getNumber(int paramInt1, int paramInt2)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append(paramInt1);
    for (int i = localStringBuilder.length(); i < paramInt2; i++) {
      localStringBuilder.insert(0, " ");
    }
    localStringBuilder.append(" ");
    
    return localStringBuilder.toString();
  }
  
  private static final class LineTokenizer
  {
    private int myPos;
    private int myLength;
    private String myValue;
    private StringBuilder myBuilder;
    
    public LineTokenizer(String paramString)
    {
      myValue = paramString;
      myLength = paramString.length();
      myBuilder = new StringBuilder();
    }
    
    public boolean hasMoreTokens()
    {
      return myPos < myLength;
    }
    
    public String nextToken()
    {
      myBuilder.setLength(0);
      String str = "";
      while (myPos < myLength)
      {
        char c = myValue.charAt(myPos);
        myPos += 1;
        if ((c == '\r') || (c == '\n'))
        {
          if ((c != '\r') || (myPos >= myLength) || (myValue.charAt(myPos) != '\n')) {
            break;
          }
          myPos += 1; break;
        }
        myBuilder.append(c);
      }
      return myBuilder.toString();
    }
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentDocument
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Color;
import java.awt.Font;

final class ComponentLine$Symbol
{
  private char myChar;
  private Font myFont;
  private Color myColor;
  
  ComponentLine$Symbol(char paramChar, Font paramFont, Color paramColor)
  {
    myChar = paramChar;
    myFont = paramFont;
    myColor = paramColor;
  }
  
  char getChar()
  {
    return myChar;
  }
  
  Font getFont()
  {
    return myFont;
  }
  
  Color getColor()
  {
    return myColor;
  }
  
  void setColor(Color paramColor)
  {
    myColor = paramColor;
  }
  
  public String toString()
  {
    return "'" + myChar + "' " + getString(myFont) + " " + getString(myColor);
  }
  
  private String getString(Color paramColor)
  {
    return "(" + paramColor.getRed() + ", " + paramColor.getGreen() + ", " + paramColor.getBlue() + ")";
  }
  
  private String getString(Font paramFont)
  {
    String str = "";
    if (paramFont.isBold()) {
      str = str + "bold";
    }
    if (paramFont.isItalic()) {
      str = str + " italic";
    } else {
      str = str + " plain";
    }
    return "[" + paramFont.getName() + ", " + str + ", " + paramFont.getSize() + "]";
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentLine.Symbol
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
import java.awt.geom.Rectangle2D;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.List;
import org.netbeans.modules.print.util.Config;
import org.netbeans.modules.print.util.UI;
import org.openide.text.AttributedCharacters;

final class ComponentLine
{
  private Font myFont;
  private Color myColor;
  private TextLayout myTextLayout;
  
  ComponentLine(AttributedCharacterIterator paramAttributedCharacterIterator, Font paramFont, Color paramColor)
  {
    int j;
    for (int i = paramAttributedCharacterIterator.first(); i != 65535; j = paramAttributedCharacterIterator.next())
    {
      Font localFont = (Font)paramAttributedCharacterIterator.getAttribute(TextAttribute.FONT);
      Color localColor = (Color)paramAttributedCharacterIterator.getAttribute(TextAttribute.FOREGROUND);
      mySymbols.add(new Symbol(i, createFont(localFont, paramFont), createColor(localColor, paramColor)));
    }
    checkSpaces(paramFont, paramColor);
  }
  
  ComponentLine(String paramString, Font paramFont, Color paramColor)
  {
    for (int i = 0; i < paramString.length(); i++) {
      mySymbols.add(new Symbol(paramString.charAt(i), paramFont, paramColor));
    }
    checkSpaces(paramFont, paramColor);
  }
  
  private ComponentLine(List<Symbol> paramList, Font paramFont, Color paramColor)
  {
    mySymbols = paramList;
    checkSpaces(paramFont, paramColor);
  }
  
  private Font createFont(Font paramFont1, Font paramFont2)
  {
    if (!Config.getDefault().isUseFont()) {
      return paramFont2;
    }
    String str = paramFont2.getName();
    int i = paramFont2.getSize();
    int j = paramFont1.getStyle();
    return new Font(str, j, i);
  }
  
  private Color createColor(Color paramColor1, Color paramColor2)
  {
    if (Config.getDefault().isUseColor()) {
      return paramColor1;
    }
    return paramColor2;
  }
  
  private void checkSpaces(Font paramFont, Color paramColor)
  {
    int i = length() - 1;
    myFont = paramFont;
    myColor = paramColor;
    while ((i >= 1) && (((Symbol)mySymbols.get(i)).getChar() == ' ')) {
      i--;
    }
    mySymbols = mySymbols.subList(0, i + 1);
    if (length() == 0) {
      mySymbols.add(new Symbol(' ', paramFont, paramColor));
    }
  }
  
  void prepend(String paramString)
  {
    Font localFont1 = ((Symbol)mySymbols.get(0)).getFont();
    
    String str = localFont1.getName();
    int i = localFont1.getSize();
    
    Font localFont2 = new Font(str, 0, i);
    for (int j = paramString.length() - 1; j >= 0; j--) {
      mySymbols.add(0, new Symbol(paramString.charAt(j), localFont2, myColor));
    }
  }
  
  boolean isEmpty()
  {
    for (int i = 0; i < length(); i++) {
      if (((Symbol)mySymbols.get(i)).getChar() != ' ') {
        return false;
      }
    }
    return true;
  }
  
  int length()
  {
    return mySymbols.size();
  }
  
  ComponentLine substring(int paramInt1, int paramInt2)
  {
    ArrayList localArrayList = new ArrayList();
    for (int i = paramInt1; i < paramInt2; i++) {
      localArrayList.add(mySymbols.get(i));
    }
    return new ComponentLine(localArrayList, myFont, myColor);
  }
  
  ComponentLine substring(int paramInt)
  {
    return substring(paramInt, mySymbols.size());
  }
  
  int getAscent()
  {
    return (int)Math.ceil(getTextLayout().getAscent());
  }
  
  int getDescent()
  {
    return (int)Math.ceil(getTextLayout().getDescent());
  }
  
  int getLeading()
  {
    return (int)Math.ceil(getTextLayout().getLeading());
  }
  
  int getWidth()
  {
    int i = getOffset();
    if (i > 0) {
      i = 0;
    }
    return (int)Math.ceil(getTextLayout().getBounds().getMaxX() - i);
  }
  
  int getOffset()
  {
    return (int)Math.ceil(getTextLayout().getBounds().getX());
  }
  
  void draw(Graphics2D paramGraphics2D, int paramInt1, int paramInt2)
  {
    getTextLayout().draw(paramGraphics2D, paramInt1, paramInt2);
  }
  
  private TextLayout getTextLayout()
  {
    if (myTextLayout == null) {
      myTextLayout = new TextLayout(getIterator(), Config.FONT_RENDER_CONTEXT);
    }
    return myTextLayout;
  }
  
  private AttributedCharacterIterator getIterator()
  {
    AttributedCharacters localAttributedCharacters = new AttributedCharacters();
    for (int i = 0; i < length(); i++) {
      localAttributedCharacters.append(((Symbol)mySymbols.get(i)).getChar(), ((Symbol)mySymbols.get(i)).getFont(), ((Symbol)mySymbols.get(i)).getColor());
    }
    return localAttributedCharacters.iterator();
  }
  
  int lastIndexOf(char paramChar, int paramInt)
  {
    for (int i = paramInt; i >= 0; i--) {
      if (((Symbol)mySymbols.get(i)).getChar() == paramChar) {
        return i;
      }
    }
    return -1;
  }
  
  public String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    for (int i = 0; i < length(); i++) {
      localStringBuilder.append(((Symbol)mySymbols.get(i)).getChar());
    }
    return localStringBuilder.toString();
  }
  
  void show()
  {
    for (int i = 0; i < length(); i++) {
      UI.out(mySymbols.get(i));
    }
  }
  
  private static final class Symbol
  {
    private char myChar;
    private Font myFont;
    private Color myColor;
    
    Symbol(char paramChar, Font paramFont, Color paramColor)
    {
      myChar = paramChar;
      myFont = paramFont;
      myColor = paramColor;
    }
    
    char getChar()
    {
      return myChar;
    }
    
    Font getFont()
    {
      return myFont;
    }
    
    Color getColor()
    {
      return myColor;
    }
    
    void setColor(Color paramColor)
    {
      myColor = paramColor;
    }
    
    public String toString()
    {
      return "'" + myChar + "' " + getString(myFont) + " " + getString(myColor);
    }
    
    private String getString(Color paramColor)
    {
      return "(" + paramColor.getRed() + ", " + paramColor.getGreen() + ", " + paramColor.getBlue() + ")";
    }
    
    private String getString(Font paramFont)
    {
      String str = "";
      if (paramFont.isBold()) {
        str = str + "bold";
      }
      if (paramFont.isItalic()) {
        str = str + " italic";
      } else {
        str = str + " plain";
      }
      return "[" + paramFont.getName() + ", " + str + ", " + paramFont.getSize() + "]";
    }
  }
  
  private List<Symbol> mySymbols = new ArrayList();
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentLine
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import javax.swing.JComponent;
import org.netbeans.spi.print.PrintPage;

final class ComponentPage
  implements PrintPage
{
  private int myRow;
  private int myColumn;
  private double myZoom;
  private Rectangle myPiece;
  private JComponent myComponent;
  
  ComponentPage(JComponent paramJComponent, Rectangle paramRectangle, double paramDouble, int paramInt1, int paramInt2)
  {
    myComponent = paramJComponent;
    myPiece = paramRectangle;
    myZoom = paramDouble;
    myRow = paramInt1;
    myColumn = paramInt2;
  }
  
  int getRow()
  {
    return myRow;
  }
  
  int getColumn()
  {
    return myColumn;
  }
  
  public void print(Graphics paramGraphics)
  {
    Graphics2D localGraphics2D = (Graphics2D)paramGraphics.create(0, 0, myPiece.width, myPiece.height);
    localGraphics2D.translate(-myPiece.x, -myPiece.y);
    localGraphics2D.scale(myZoom, myZoom);
    myComponent.print(localGraphics2D);
    localGraphics2D.dispose();
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentPage
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.util.Comparator;
import javax.swing.JComponent;

class ComponentPanel$1
  implements Comparator<JComponent>
{
  ComponentPanel$1(ComponentPanel paramComponentPanel) {}
  
  public int compare(JComponent paramJComponent1, JComponent paramJComponent2)
  {
    int i = getInteger(paramJComponent1).intValue();
    int j = getInteger(paramJComponent2).intValue();
    if (i < j) {
      return -1;
    }
    if (i == j) {
      return 0;
    }
    return 1;
  }
  
  private Integer getInteger(JComponent paramJComponent)
  {
    Object localObject = paramJComponent.getClientProperty("print.order");
    if ((localObject instanceof Integer)) {
      return (Integer)localObject;
    }
    return Integer.valueOf(Integer.MIN_VALUE);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentPanel.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Dimension;
import java.awt.Graphics;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JPanel;

final class ComponentPanel
  extends JPanel
{
  private int myWidth;
  private int myHeight;
  private List<JComponent> myComponents;
  
  ComponentPanel(List<JComponent> paramList)
  {
    myComponents = sort(paramList);
    
    myHeight = 0;
    myWidth = 0;
    for (int i = 0; i < myComponents.size(); i++)
    {
      JComponent localJComponent = (JComponent)myComponents.get(i);
      
      int j = getWidth(localJComponent);
      int k = getHeight(localJComponent);
      
      myWidth += j;
      if (k > myHeight) {
        myHeight = k;
      }
    }
  }
  
  public void print(Graphics paramGraphics)
  {
    for (JComponent localJComponent : myComponents)
    {
      localJComponent.print(paramGraphics);
      
      paramGraphics.translate(getWidth(localJComponent), 0);
    }
  }
  
  public int getWidth()
  {
    return myWidth;
  }
  
  public int getHeight()
  {
    return myHeight;
  }
  
  private int getWidth(JComponent paramJComponent)
  {
    Dimension localDimension = getSize(paramJComponent);
    if (localDimension == null) {
      return paramJComponent.getWidth();
    }
    return width;
  }
  
  private int getHeight(JComponent paramJComponent)
  {
    Dimension localDimension = getSize(paramJComponent);
    if (localDimension == null) {
      return paramJComponent.getHeight();
    }
    return height;
  }
  
  private Dimension getSize(JComponent paramJComponent)
  {
    Object localObject = paramJComponent.getClientProperty("print.size");
    if ((localObject instanceof Dimension)) {
      return (Dimension)localObject;
    }
    return null;
  }
  
  private List<JComponent> sort(List<JComponent> paramList)
  {
    Collections.sort(paramList, new Comparator()
    {
      public int compare(JComponent paramAnonymousJComponent1, JComponent paramAnonymousJComponent2)
      {
        int i = getInteger(paramAnonymousJComponent1).intValue();
        int j = getInteger(paramAnonymousJComponent2).intValue();
        if (i < j) {
          return -1;
        }
        if (i == j) {
          return 0;
        }
        return 1;
      }
      
      private Integer getInteger(JComponent paramAnonymousJComponent)
      {
        Object localObject = paramAnonymousJComponent.getClientProperty("print.order");
        if ((localObject instanceof Integer)) {
          return (Integer)localObject;
        }
        return Integer.valueOf(Integer.MIN_VALUE);
      }
    });
    return paramList;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentPanel
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.swing.JComponent;
import org.netbeans.modules.print.util.Percent;
import org.netbeans.spi.print.PrintPage;
import org.netbeans.spi.print.PrintProvider;

public class ComponentProvider
  implements PrintProvider
{
  private String myName;
  private Date myLastModified;
  private JComponent myComponent;
  
  public ComponentProvider(List<JComponent> paramList, String paramString, Date paramDate)
  {
    myName = paramString;
    myLastModified = paramDate;
    if (paramList != null) {
      myComponent = new ComponentPanel(paramList);
    }
  }
  
  protected JComponent getComponent()
  {
    return myComponent;
  }
  
  public PrintPage[][] getPages(int paramInt1, int paramInt2, double paramDouble)
  {
    ArrayList localArrayList = new ArrayList();
    JComponent localJComponent = getComponent();
    if (localJComponent == null) {
      return new PrintPage[0][0];
    }
    int i = localJComponent.getWidth();
    int j = localJComponent.getHeight();
    
    double d = getZoom(paramDouble, paramInt1, paramInt2, i, j);
    
    i = (int)Math.floor(i * d);
    j = (int)Math.floor(j * d);
    
    int k = 0;
    int m = 0;
    Object localObject;
    for (int n = 0; n < j; n += paramInt2)
    {
      k++;
      m = 0;
      for (int i1 = 0; i1 < i; i1 += paramInt1)
      {
        m++;
        localObject = new Rectangle((m - 1) * paramInt1, (k - 1) * paramInt2, paramInt1, paramInt2);
        localArrayList.add(new ComponentPage(localJComponent, (Rectangle)localObject, d, k - 1, m - 1));
      }
    }
    PrintPage[][] arrayOfPrintPage = new PrintPage[k][m];
    for (Iterator localIterator = localArrayList.iterator(); localIterator.hasNext();)
    {
      localObject = (ComponentPage)localIterator.next();
      arrayOfPrintPage[localObject.getRow()][localObject.getColumn()] = localObject;
    }
    return arrayOfPrintPage;
  }
  
  private double getZoom(double paramDouble, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    double d = Percent.getZoomFactor(paramDouble, -1.0D);
    if (0.0D < d) {
      return d;
    }
    if (Percent.isZoomPage(paramDouble)) {
      d = 0.0D;
    }
    int i = Percent.getZoomWidth(paramDouble, -1);
    int j = Percent.getZoomHeight(paramDouble, -1);
    if (d == 0.0D)
    {
      i = 1;
      j = 1;
    }
    return getZoom(paramInt1 * i / paramInt3, paramInt2 * j / paramInt4);
  }
  
  private double getZoom(double paramDouble1, double paramDouble2)
  {
    if ((paramDouble1 > 0.0D) && (paramDouble2 > 0.0D)) {
      return Math.min(paramDouble1, paramDouble2);
    }
    if ((paramDouble1 < 0.0D) && (paramDouble2 > 0.0D)) {
      return paramDouble2;
    }
    if ((paramDouble1 > 0.0D) && (paramDouble2 < 0.0D)) {
      return paramDouble1;
    }
    return 1.0D;
  }
  
  public String getName()
  {
    return myName;
  }
  
  public Date lastModified()
  {
    return myLastModified;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.modules.print.provider.ComponentProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.modules.print.provider;

import java.awt.Component;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.text.BadLocationException;
import javax.swing.text.Document;
import javax.swing.text.JTextComponent;
import javax.swing.text.StyledDocument;
import org.netbeans.modules.print.util.Config;
import org.openide.cookies.EditorCookie;
import org.openide.util.Lookup;

public final class EditorProvider
  extends ComponentProvider
{
  private EditorCookie myEditor;
  
  public EditorProvider(EditorCookie paramEditorCookie, Date paramDate)
  {
    super(null, getName(paramEditorCookie), paramDate);
    myEditor = paramEditorCookie;
  }
  
  protected JComponent getComponent()
  {
    JTextComponent localJTextComponent = getTextComponent();
    if (localJTextComponent == null) {
      return null;
    }
    if (Config.getDefault().isAsEditor()) {
      return getEditorComponent(localJTextComponent);
    }
    StyledDocument localStyledDocument = myEditor.getDocument();
    if (localStyledDocument == null) {
      return null;
    }
    int i;
    int j;
    if (Config.getDefault().isSelection())
    {
      i = localJTextComponent.getSelectionStart();
      j = localJTextComponent.getSelectionEnd();
    }
    else
    {
      i = 0;
      j = localStyledDocument.getLength();
    }
    AttributedCharacterIterator[] arrayOfAttributedCharacterIterator = getIterators(localStyledDocument, i, j);
    if (arrayOfAttributedCharacterIterator != null) {
      return new ComponentDocument(arrayOfAttributedCharacterIterator);
    }
    try
    {
      return new ComponentDocument(localJTextComponent.getText(i, j - i));
    }
    catch (BadLocationException localBadLocationException) {}
    return null;
  }
  
  private AttributedCharacterIterator[] getIterators(Document paramDocument, int paramInt1, int paramInt2)
  {
    ActionListener localActionListener = (ActionListener)Lookup.getDefault().lookup(ActionListener.class);
    if (localActionListener == null) {
      return null;
    }
    if (!localActionListener.getClass().getName().contains(".print.")) {
      return null;
    }
    ArrayList localArrayList = new ArrayList();
    localArrayList.add(paramDocument);
    localArrayList.add(Integer.valueOf(paramInt1));
    localArrayList.add(Integer.valueOf(paramInt2));
    ActionEvent localActionEvent = new ActionEvent(localArrayList, 0, null);
    localActionListener.actionPerformed(localActionEvent);
    Object localObject1 = localActionEvent.getSource();
    if (!(localObject1 instanceof List)) {
      return null;
    }
    List localList = (List)localObject1;
    if (localList.size() != 4) {
      return null;
    }
    Object localObject2 = localList.get(3);
    if (!(localObject2 instanceof AttributedCharacterIterator[])) {
      return null;
    }
    return (AttributedCharacterIterator[])localObject2;
  }
  
  private static String getName(EditorCookie paramEditorCookie)
  {
    StyledDocument localStyledDocument = paramEditorCookie.getDocument();
    if (localStyledDocument == null) {
      return null;
    }
    return ((String)localStyledDocument.getProperty("title")).replace('\\', '/');
  }
  
  private JTextComponent getTextComponent()
  {
    JEditorPane[] arrayOfJEditorPane = myEditor.getOpenedPanes();
    if ((arrayOfJEditorPane == null) || (arrayOfJEditorPane.length == 0)) {
      return null;
    }
    return arrayOfJEditorPane[0];
  }
  
  private JComponent getEditorComponent(JComponent paramJComponent)
  {
    if (!Config.getDefault().isLineNumbers()) {
      return paramJComponent;
    }
    JComponent localJComponent = getLineNumberComponent(getParent(paramJComponent));
    if (localJComponent == null) {
      return paramJComponent;
    }
    ArrayList localArrayList = new ArrayList();
    
    localArrayList.add(localJComponent);
    localArrayList.add(paramJComponent);
    
    return new ComponentPanel(localArrayList);
  }
  
  private JComponent getLineNumberComponent(Component paramComponent)
  {
    if (paramComponent == null) {
      return null;
    }
    if ((para
1 2 3 4 5

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd