当前位置: 首页>>代码示例>>Java>>正文


Java PrintManager类代码示例

本文整理汇总了Java中com.trollworks.toolkit.ui.print.PrintManager的典型用法代码示例。如果您正苦于以下问题:Java PrintManager类的具体用法?Java PrintManager怎么用?Java PrintManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PrintManager类属于com.trollworks.toolkit.ui.print包,在下文中一共展示了PrintManager类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setDefaultPageSettings

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/** @param mgr The {@Link PrintManager} to record the settings for. */
public static void setDefaultPageSettings(PrintManager mgr) {
    String value = null;
    if (mgr != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try (XMLWriter out = new XMLWriter(baos)) {
            out.writeHeader();
            mgr.save(out, LengthUnits.IN);
        } catch (Exception exception) {
            Log.error(exception);
        }
        if (baos.size() > 0) {
            value = new String(baos.toByteArray(), StandardCharsets.UTF_8);
        }
    }
    Preferences.getInstance().setValue(MODULE, DEFAULT_PAGE_SETTINGS_KEY, value);
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:18,代码来源:OutputPreferences.java

示例2: getPrintManager

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
@Override
public PrintManager getPrintManager() {
    if (mPrintManager == null) {
        try {
            mPrintManager = mCharacter.getPageSettings();
        } catch (Exception exception) {
            // Ignore
        }
    }
    return mPrintManager;
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:12,代码来源:CharacterSheet.java

示例3: itemStateChanged

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
@Override
public void itemStateChanged(ItemEvent event) {
    Object source = event.getSource();
    if (source == mUseTextTemplateOverride) {
        boolean checked = mUseTextTemplateOverride.isSelected();
        Preferences.getInstance().setValue(MODULE, USE_TEMPLATE_OVERRIDE_KEY, checked);
        mTextTemplatePath.setEnabled(checked);
        mTextTemplatePicker.setEnabled(checked);
        mTextTemplatePath.setText(getTextTemplate());
    } else if (source == mUseNativePrinter) {
        PrintManager.useNativeDialogs(mUseNativePrinter.isSelected());
    }
    adjustResetButton();
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:15,代码来源:OutputPreferences.java

示例4: Page

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/**
 * Creates a new page.
 *
 * @param owner The page owner.
 */
public Page(PageOwner owner) {
    super(new BorderLayout());
    mOwner = owner;
    setOpaque(true);
    setBackground(Color.white);
    PrintManager pageSettings = mOwner.getPageSettings();
    Insets insets = mOwner.getPageAdornmentsInsets(this);
    double[] margins = pageSettings != null ? pageSettings.getPageMargins(LengthUnits.PT) : new double[] { 36.0, 36.0, 36.0, 36.0 };
    setBorder(new EmptyBorder(insets.top + (int) margins[0], insets.left + (int) margins[1], insets.bottom + (int) margins[2], insets.right + (int) margins[3]));
    double[] size = mOwner.getScale().scale(pageSettings != null ? pageSettings.getPageSize(LengthUnits.PT) : new double[] { 8.5 * 72.0, 11.0 * 72.0 });
    Dimension pageSize = new Dimension((int) size[0], (int) size[1]);
    UIUtilities.setOnlySize(this, pageSize);
    setSize(pageSize);
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:20,代码来源:Page.java

示例5: print

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/** @param proxy The {@link PrintProxy} to print. */
public static void print(PrintProxy proxy) {
	if (proxy != null) {
		PrintManager mgr = proxy.getPrintManager();
		if (mgr != null) {
			mgr.print(proxy);
		} else {
			WindowUtils.showError(UIUtilities.getComponentForDialog(proxy), NO_PRINTER_SELECTED);
		}
	}
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:12,代码来源:PrintCommand.java

示例6: actionPerformed

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
@Override
public void actionPerformed(ActionEvent event) {
	PrintProxy proxy = getTarget(PrintProxy.class);
	if (proxy != null) {
		PrintManager mgr = proxy.getPrintManager();
		if (mgr != null) {
			mgr.pageSetup(proxy);
		} else {
			WindowUtils.showError(UIUtilities.getComponentForDialog(proxy), NO_PRINTER_SELECTED);
		}
	}
}
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:13,代码来源:PageSetupCommand.java

示例7: getPageSettings

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
@Override
public PrintManager getPageSettings() {
    return mCharacter.getPageSettings();
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:5,代码来源:CharacterSheet.java

示例8: saveAsPDF

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/**
 * @param file The file to save to.
 * @return <code>true</code> on success.
 */
public boolean saveAsPDF(File file) {
    HashSet<Row> changed = expandAllContainers();
    try {
        PrintManager settings = mCharacter.getPageSettings();
        PageFormat format = settings != null ? settings.createPageFormat() : createDefaultPageFormat();
        Paper paper = format.getPaper();
        float width = (float) paper.getWidth();
        float height = (float) paper.getHeight();

        adjustToPageSetupChanges(true);
        setPrinting(true);

        com.lowagie.text.Document pdfDoc = new com.lowagie.text.Document(new com.lowagie.text.Rectangle(width, height));
        try (FileOutputStream out = new FileOutputStream(file)) {
            PdfWriter writer = PdfWriter.getInstance(pdfDoc, out);
            int pageNum = 0;
            PdfContentByte cb;

            pdfDoc.open();
            cb = writer.getDirectContent();
            while (true) {
                PdfTemplate template = cb.createTemplate(width, height);
                Graphics2D g2d = template.createGraphics(width, height, new DefaultFontMapper());

                if (print(g2d, format, pageNum) == NO_SUCH_PAGE) {
                    g2d.dispose();
                    break;
                }
                if (pageNum != 0) {
                    pdfDoc.newPage();
                }
                g2d.setClip(0, 0, (int) width, (int) height);
                print(g2d, format, pageNum++);
                g2d.dispose();
                cb.addTemplate(template, 0, 0);
            }
            pdfDoc.close();
        }
        return true;
    } catch (Exception exception) {
        return false;
    } finally {
        setPrinting(false);
        closeContainers(changed);
    }
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:51,代码来源:CharacterSheet.java

示例9: saveAsPNG

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/**
 * @param file The file to save to.
 * @param createdFiles The files that were created.
 * @return <code>true</code> on success.
 */
public boolean saveAsPNG(File file, ArrayList<File> createdFiles) {
    HashSet<Row> changed = expandAllContainers();
    try {
        int dpi = OutputPreferences.getPNGResolution();
        PrintManager settings = mCharacter.getPageSettings();
        PageFormat format = settings != null ? settings.createPageFormat() : createDefaultPageFormat();
        Paper paper = format.getPaper();
        int width = (int) (paper.getWidth() / 72.0 * dpi);
        int height = (int) (paper.getHeight() / 72.0 * dpi);
        StdImage buffer = StdImage.create(width, height, Transparency.OPAQUE);
        int pageNum = 0;
        String name = PathUtils.getLeafName(file.getName(), false);

        file = file.getParentFile();

        adjustToPageSetupChanges(true);
        setPrinting(true);

        while (true) {
            File pngFile;

            Graphics2D gc = buffer.getGraphics();
            if (print(gc, format, pageNum) == NO_SUCH_PAGE) {
                gc.dispose();
                break;
            }
            gc.setClip(0, 0, width, height);
            gc.setBackground(Color.WHITE);
            gc.clearRect(0, 0, width, height);
            gc.scale(dpi / 72.0, dpi / 72.0);
            print(gc, format, pageNum++);
            gc.dispose();
            pngFile = new File(file, PathUtils.enforceExtension(name + (pageNum > 1 ? " " + pageNum : ""), FileType.PNG_EXTENSION)); //$NON-NLS-1$ //$NON-NLS-2$
            if (!StdImage.writePNG(pngFile, buffer, dpi)) {
                throw new IOException();
            }
            createdFiles.add(pngFile);
        }
        return true;
    } catch (Exception exception) {
        return false;
    } finally {
        setPrinting(false);
        closeContainers(changed);
    }
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:52,代码来源:CharacterSheet.java

示例10: getPageSettings

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/** @return The page settings. May return <code>null</code> if no printer has been defined. */
public PrintManager getPageSettings() {
    return mPageSettings;
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:5,代码来源:GURPSCharacter.java

示例11: loadSelf

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
@Override
protected final void loadSelf(XMLReader reader, LoadState state) throws IOException {
    String marker = reader.getMarker();
    int unspentPoints = 0;

    characterInitialize(false);
    do {
        if (reader.next() == XMLNodeType.START_TAG) {
            String name = reader.getName();

            if (state.mDataFileVersion == 0) {
                if (mDescription.loadTag(reader, name)) {
                    continue;
                }
            }

            if (Profile.TAG_ROOT.equals(name)) {
                mDescription.load(reader);
            } else if (TAG_CREATED_DATE.equals(name)) {
                mCreatedOn = Numbers.extractDate(reader.readText());
            } else if (TAG_MODIFIED_DATE.equals(name)) {
                mLastModified = Numbers.extractDateTime(reader.readText());
            } else if (BonusAttributeType.HP.getXMLTag().equals(name)) {
                mHitPoints = reader.readInteger(0);
            } else if (TAG_CURRENT_HP.equals(name)) {
                mCurrentHitPoints = reader.readText();
            } else if (BonusAttributeType.FP.getXMLTag().equals(name)) {
                mFatiguePoints = reader.readInteger(0);
            } else if (TAG_CURRENT_FP.equals(name)) {
                mCurrentFatiguePoints = reader.readText();
            } else if (TAG_UNSPENT_POINTS.equals(name)) {
                unspentPoints = reader.readInteger(0);
            } else if (TAG_TOTAL_POINTS.equals(name)) {
                mTotalPoints = reader.readInteger(0);
            } else if (BonusAttributeType.ST.getXMLTag().equals(name)) {
                mStrength = reader.readInteger(0);
            } else if (BonusAttributeType.DX.getXMLTag().equals(name)) {
                mDexterity = reader.readInteger(0);
            } else if (BonusAttributeType.IQ.getXMLTag().equals(name)) {
                mIntelligence = reader.readInteger(0);
            } else if (BonusAttributeType.HT.getXMLTag().equals(name)) {
                mHealth = reader.readInteger(0);
            } else if (BonusAttributeType.WILL.getXMLTag().equals(name)) {
                mWill = reader.readInteger(0);
            } else if (BonusAttributeType.PERCEPTION.getXMLTag().equals(name)) {
                mPerception = reader.readInteger(0);
            } else if (BonusAttributeType.SPEED.getXMLTag().equals(name)) {
                mSpeed = reader.readDouble(0.0);
            } else if (BonusAttributeType.MOVE.getXMLTag().equals(name)) {
                mMove = reader.readInteger(0);
            } else if (TAG_INCLUDE_PUNCH.equals(name)) {
                mIncludePunch = reader.readBoolean();
            } else if (TAG_INCLUDE_KICK.equals(name)) {
                mIncludeKick = reader.readBoolean();
            } else if (TAG_INCLUDE_BOOTS.equals(name)) {
                mIncludeKickBoots = reader.readBoolean();
            } else if (AdvantageList.TAG_ROOT.equals(name)) {
                loadAdvantageList(reader, state);
            } else if (SkillList.TAG_ROOT.equals(name)) {
                loadSkillList(reader, state);
            } else if (SpellList.TAG_ROOT.equals(name)) {
                loadSpellList(reader, state);
            } else if (EquipmentList.TAG_ROOT.equals(name)) {
                loadEquipmentList(reader, state);
            } else if (NoteList.TAG_ROOT.equals(name)) {
                loadNoteList(reader, state);
            } else if (PrintManager.TAG_ROOT.equals(name)) {
                if (mPageSettings != null) {
                    mPageSettings.load(reader);
                }
            } else {
                reader.skipTag(name);
            }
        }
    } while (reader.withinMarker(marker));

    calculateAll();
    if (unspentPoints != 0) {
        setUnspentPoints(unspentPoints);
    }
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:82,代码来源:GURPSCharacter.java

示例12: isSetToDefaults

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
@Override
public boolean isSetToDefaults() {
    return getPNGResolution() == DEFAULT_PNG_RESOLUTION && isTextTemplateOverridden() == false && !PrintManager.useNativeDialogs() && mGurpsCalculatorKey.getText().equals("") && mBlockLayoutField.getText().equals(DEFAULT_BLOCK_LAYOUT); //$NON-NLS-1$
}
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:5,代码来源:OutputPreferences.java

示例13: getPageSettings

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/** @return The page settings. */
public PrintManager getPageSettings();
 
开发者ID:richardwilkes,项目名称:gcs,代码行数:3,代码来源:PageOwner.java

示例14: getPrintManager

import com.trollworks.toolkit.ui.print.PrintManager; //导入依赖的package包/类
/** @return The {@link PrintManager} to use. */
PrintManager getPrintManager();
 
开发者ID:Ayutac,项目名称:toolkit,代码行数:3,代码来源:PrintProxy.java


注:本文中的com.trollworks.toolkit.ui.print.PrintManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。