PrinterPort.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.*;
16: import java.awt.event.*;
17: import java.awt.image.*;
18: import java.io.*;
19: import javax.imageio.*;
20: import javax.imageio.metadata.*;
21: import javax.imageio.stream.*;
22: import javax.swing.*;
23: import javax.swing.event.*;
24: import java.util.*;
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222: public class PrinterPort {
223:
224:
225:
226:
227:
228: public static final int PRN_DATA = 0x00e8c001;
229: public static final int PRN_STROBE = 0x00e8c003;
230: public static int prnData;
231: public static int prnStrobe;
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260: public static final boolean PRN_USE_ADAPTER = true;
261: public static final int PRN_ADAPTER_CAPACITY = 1024;
262: public static final long PRN_ADAPTER_DELAY = XEiJ.TMR_FREQ * 10000 / 1000000;
263: public static byte[] prnAdapterBuffer;
264: public static int prnAdapterPointer;
265: public static TickerQueue.Ticker prnAdapterTicker;
266: public static java.util.Timer prnAdapterTimer;
267:
268:
269:
270: public static void prnAdapterInit () {
271: prnAdapterBuffer = new byte[PRN_ADAPTER_CAPACITY];
272: prnAdapterPointer = 0;
273: prnAdapterTicker = new PrinterAdapterTicker ();
274: prnAdapterTimer = new java.util.Timer ();
275: }
276:
277:
278:
279: public static void prnAdapterOutput (int data) {
280:
281: prnAdapterBuffer[prnAdapterPointer++] = (byte) data;
282: if (prnAdapterPointer < PRN_ADAPTER_CAPACITY) {
283:
284: TickerQueue.tkqAdd (prnAdapterTicker, XEiJ.mpuClockTime + PRN_ADAPTER_DELAY);
285: } else {
286:
287: TickerQueue.tkqRemove (prnAdapterTicker);
288:
289: prnAdapterTaskLauncher ();
290: }
291: }
292:
293:
294:
295: public static class PrinterAdapterTicker extends TickerQueue.Ticker {
296: @Override protected void tick () {
297:
298: prnAdapterTaskLauncher ();
299: }
300: };
301:
302:
303:
304: public static void prnAdapterTaskLauncher () {
305:
306: byte[] copiedBuffer = Arrays.copyOf (prnAdapterBuffer, prnAdapterPointer);
307:
308: prnAdapterPointer = 0;
309:
310: prnAdapterTimer.schedule (new PrinterAdapterTask (copiedBuffer), 100L);
311: }
312:
313:
314:
315: public static class PrinterAdapterTask extends TimerTask {
316: private byte[] buffer;
317: public PrinterAdapterTask (byte[] copiedBuffer) {
318: buffer = copiedBuffer;
319: }
320: @Override public void run () {
321:
322: for (int i = 0; i < buffer.length; i++) {
323: prnOutput (buffer[i]);
324: }
325: }
326: }
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344: public static IndexColorModel prnImageColorModel;
345: public static IndexColorModel prnDarkImageColorModel;
346:
347:
348:
349:
350:
351: public static final int PRN_MAX_WIDTH_DOT = 360 * 48;
352: public static final int PRN_MAX_HEIGHT_DOT = 360 * 66;
353: public static final int PRN_MAX_WIDTH_MM = (int) Math.floor ((double) PRN_MAX_WIDTH_DOT * 25.4 / 360.0);
354: public static final int PRN_MAX_HEIGHT_MM = (int) Math.floor ((double) PRN_MAX_HEIGHT_DOT * 25.4 / 360.0);
355:
356:
357: public static final int PRN_A_SERIES = 0;
358: public static final int PRN_B_SERIES = 1;
359: public static final int PRN_POSTCARD = 2;
360:
361:
362: public static final int PRN_PORTRAIT = 0;
363: public static final int PRN_LANDSCAPE = 1;
364:
365:
366:
367:
368:
369: public static class Paper {
370:
371:
372: public String sizeEn;
373: public String sizeJa;
374:
375: public String orientationEn;
376: public String orientationJa;
377:
378: public int paperWidthMm;
379: public int paperHeightMm;
380: public int paperWidthDot;
381: public int paperHeightDot;
382:
383:
384: public int initialDeadTopMm;
385: public int initialDeadLeftMm;
386: public int initialDeadRightMm;
387: public int initialDeadBottomMm;
388:
389: public String nameEn;
390: public String nameJa;
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405: public Paper (int series, int n, int orientation) {
406:
407: int narrowMm;
408: int longMm;
409:
410: if (series == PRN_A_SERIES) {
411: narrowMm = (int) Math.floor (1000.0 / Math.pow (2.0, (double) (2 * n + 1) * 0.25) + 0.2);
412: longMm = (int) Math.floor (1000.0 / Math.pow (2.0, (double) (2 * n - 1) * 0.25) + 0.2);
413: initialDeadTopMm = 11;
414: initialDeadLeftMm = 14;
415: initialDeadRightMm = 14;
416: initialDeadBottomMm = 11;
417: sizeEn = n < 0 ? (1 << -n) + "A0" : "A" + n;
418: sizeJa = sizeEn;
419: } else if (series == PRN_B_SERIES) {
420: narrowMm = (int) Math.floor (1000.0 * Math.sqrt (3.0) / Math.pow (2.0, (double) (2 * n + 3) * 0.25) + 0.2);
421: longMm = (int) Math.floor (1000.0 * Math.sqrt (3.0) / Math.pow (2.0, (double) (2 * n + 1) * 0.25) + 0.2);
422: initialDeadTopMm = 11;
423: initialDeadLeftMm = 24;
424: initialDeadRightMm = 24;
425: initialDeadBottomMm = 11;
426: sizeEn = n < 0 ? (1 << -n) + "B0" : "B" + n;
427: sizeJa = sizeEn;
428: } else {
429: narrowMm = 100;
430: longMm = 148;
431: initialDeadTopMm = 10;
432: initialDeadLeftMm = 3;
433: initialDeadRightMm = 3;
434: initialDeadBottomMm = 10;
435: sizeEn = "Postcard";
436: sizeJa = "はがき";
437: }
438: if (orientation == PRN_PORTRAIT) {
439: paperWidthMm = narrowMm;
440: paperHeightMm = longMm;
441: orientationEn = "portrait";
442: orientationJa = "縦";
443: } else {
444: paperWidthMm = longMm;
445: paperHeightMm = narrowMm;
446: orientationEn = "landscape";
447: orientationJa = "横";
448: }
449: paperWidthDot = (int) Math.floor ((double) paperWidthMm * (360.0 / 25.4) + 0.5);
450: paperHeightDot = (int) Math.floor ((double) paperHeightMm * (360.0 / 25.4) + 0.5);
451:
452: nameEn = sizeEn + " " + orientationEn + " " + paperWidthMm + "x" + paperHeightMm;
453: nameJa = sizeJa + " " + orientationJa + " " + paperWidthMm + "x" + paperHeightMm;
454:
455: }
456:
457: }
458:
459:
460:
461:
462: public static Paper[] prnPaperArray;
463:
464:
465: public static Paper prnNextPaper;
466: public static Paper prnCurrentPaper;
467:
468:
469:
470: public static int prnNextRotation;
471: public static int prnRotation;
472: public static int prnRotatedWidthDot;
473: public static int prnRotatedHeightDot;
474: public static int prnM11;
475: public static int prnM12;
476: public static int prnM13;
477: public static int prnM21;
478: public static int prnM22;
479: public static int prnM23;
480: public static int prnIncrementX;
481: public static int prnIncrementY;
482:
483:
484:
485: public static boolean prnNextDarkMode;
486: public static boolean prnDarkMode;
487:
488:
489: public static boolean prnOnlineOn;
490:
491:
492:
493: public static int prnSingleColor;
494:
495:
496:
497: public static int prnScaleShift;
498:
499:
500:
501: public static BufferedImage prnImage;
502: public static byte[] prnBitmap;
503:
504:
505:
506: public static boolean prnPrinted;
507:
508:
509:
510:
511:
512:
513: public static int prnMarginLeftX;
514: public static int prnMarginRightX;
515: public static int prnMarginBottomHeight;
516:
517:
518:
519:
520: public static int prnDefaultLineHeight;
521: public static int prnLineHeight;
522:
523:
524: public static final int PRN_PICA = 0;
525: public static final int PRN_ELITE = 1;
526: public static final int PRN_SMALL = 2;
527: public static int prnCharacterType;
528:
529:
530: public static boolean prnHiraganaMode;
531:
532:
533: public static final int PRN_NO_SCRIPT = 0;
534: public static final int PRN_SUPER_SCRIPT = 1;
535: public static final int PRN_SUB_SCRIPT = 2;
536: public static int prnScriptMode;
537:
538:
539: public static boolean prnStrongMode;
540:
541:
542: public static boolean prnUnderlineMode;
543:
544:
545: public static final int PRN_NORMAL_STYLE = 0;
546: public static final int PRN_OPEN_STYLE = 1;
547: public static final int PRN_SHADOW_STYLE = 2;
548: public static final int PRN_OPEN_SHADOW_STYLE = 3;
549: public static int prnCharacterStyle;
550:
551:
552: public static boolean prnKanjiMode;
553:
554:
555:
556:
557: public static byte[] prnGaijiData = null;
558:
559:
560: public static boolean prnVerticalWritingMode;
561:
562:
563: public static int prnFullWidthLeftSpace;
564: public static int prnFullWidthRightSpace;
565: public static int prnHalfWidthLeftSpace;
566: public static int prnHalfWidthRightSpace;
567:
568:
569: public static boolean prnHorizontalDoubleSizeMode;
570: public static boolean prnVerticalDoubleSizeMode;
571: public static boolean prnKanjiHorizontalDoubleSizeMode;
572:
573:
574: public static final int PRN_HORIZONTAL_ANCHOR_LIMIT = 16;
575: public static final int[] prnHorizontalTabAnchor = new int[PRN_HORIZONTAL_ANCHOR_LIMIT];
576:
577:
578: public static final int PRN_VERTICAL_ANCHOR_LIMIT = 128;
579: public static final int[] prnVerticalTabAnchor = new int[PRN_VERTICAL_ANCHOR_LIMIT];
580:
581:
582: public static boolean prnColorMode;
583:
584:
585:
586:
587:
588: public static int prnCurrentColor;
589:
590:
591: public static int prnHalfWidthFont;
592: public static int prnFullWidthFont;
593:
594:
595:
596: public static int prnNextDeadTopMm;
597: public static int prnNextDeadLeftMm;
598: public static int prnNextDeadRightMm;
599: public static int prnNextDeadBottomMm;
600: public static int prnDeadTopMm;
601: public static int prnDeadLeftMm;
602: public static int prnDeadRightMm;
603: public static int prnDeadBottomMm;
604:
605:
606:
607:
608: public static int prnAliveTopY;
609: public static int prnAliveLeftX;
610: public static int prnAliveRightX;
611: public static int prnAliveBottomY;
612:
613:
614:
615:
616:
617:
618:
619:
620:
621:
622:
623:
624:
625:
626:
627: public static int prnPageStart;
628: public static int prnPageLength;
629:
630:
631:
632:
633:
634: public static int prnContentTopY;
635: public static int prnContentBottomY;
636:
637:
638: public static int prnHeadX;
639: public static int prnHeadY;
640: public static int prnHeadLine;
641:
642:
643:
644:
645:
646:
647:
648:
649: public static final byte[] prnCommandBuffer = new byte[4 + 6 * PRN_MAX_WIDTH_DOT];
650: public static int prnCommandLength;
651: public static int prnCommandPointer;
652:
653:
654:
655: public static ScrollCanvas prnCanvas;
656: public static JFrame prnFrame;
657:
658:
659: public static JCheckBoxMenuItem prnOnlineMenuItem;
660: public static JCheckBoxMenuItem prnAutosaveMenuItem;
661:
662: public static int prnSpinnerLocked;
663: public static SpinnerNumberModel prnDeadTopModel;
664: public static SpinnerNumberModel prnDeadLeftModel;
665: public static SpinnerNumberModel prnDeadRightModel;
666: public static SpinnerNumberModel prnDeadBottomModel;
667: public static NumberSpinner prnDeadTopSpinner;
668: public static NumberSpinner prnDeadLeftSpinner;
669: public static NumberSpinner prnDeadRightSpinner;
670: public static NumberSpinner prnDeadBottomSpinner;
671: public static JRadioButtonMenuItem[] prnScaleMenuItem;
672:
673:
674: public static boolean prnAutosaveOn;
675: public static String prnSavePath;
676: public static String prnSaveName;
677: public static JDialog prnSaveDialog;
678: public static JFileChooser2 prnSaveFileChooser;
679: public static String[] prnWriterSuffixes;
680: public static javax.swing.filechooser.FileFilter prnSaveFileFilter;
681: public static JCheckBox prnAutosaveCheckBox;
682:
683:
684: public static final int PRN_DIPSW_ZERO_STYLE = 0x01;
685: public static final int PRN_DIPSW_PRINTING_SPEED = 0x02;
686: public static final int PRN_DIPSW_POSTCARD_MODE = 0x04;
687: public static final int PRN_DIPSW_PAGE_LENGTH = 0x08;
688: public static final int PRN_DIPSW_FEEDING_POSITION = 0x20;
689: public static final int PRN_DIPSW_FONT_STYLE = 0x80;
690: public static final int PRN_DIPSW_MASK = 0xaf;
691: public static int prnDIPSW;
692:
693:
694:
695:
696: public static final String FNT_EN_Zen48x48G = "Full Kanji 48x48 Gothic";
697: public static final String FNT_EN_Pic36x46S = "CZ-8PC4 Pica 36x46 Sans-Serif";
698: public static final String FNT_EN_Eli30x46S = "CZ-8PC4 Elite 30x46 Sans-Serif";
699: public static final String FNT_EN_Sma18x46S = "CZ-8PC4 Small 18x46 Sans-Serif";
700: public static final String FNT_EN_Scr28x32S = "CZ-8PC4 Script 28x32 Sans-Serif";
701: public static final String FNT_EN_Pan24x48S = "CZ-8PC4 Half 24x48 Sans-Serif";
702: public static final String FNT_EN_Zen48x48M = "Full Kanji 48x48 Mincho";
703: public static final String FNT_EN_Pic36x46R = "CZ-8PC4 Pica 36x46 Roman";
704: public static final String FNT_EN_Eli30x46R = "CZ-8PC4 Elite 30x46 Roman";
705: public static final String FNT_EN_Sma18x46R = "CZ-8PC4 Small 18x46 Roman";
706: public static final String FNT_EN_Scr28x32R = "CZ-8PC4 Script 28x32 Roman";
707: public static final String FNT_EN_Pan24x48R = "CZ-8PC4 Half 24x48 Roman";
708:
709: public static final String FNT_JA_Zen48x48G = "全角 漢字 48x48 ゴシック体";
710: public static final String FNT_JA_Pic36x46S = "CZ-8PC4 パイカ 36x46 サンセリフ体";
711: public static final String FNT_JA_Eli30x46S = "CZ-8PC4 エリート 30x46 サンセリフ体";
712: public static final String FNT_JA_Sma18x46S = "CZ-8PC4 縮小 18x46 サンセリフ体";
713: public static final String FNT_JA_Scr28x32S = "CZ-8PC4 スクリプト 28x32 サンセリフ体";
714: public static final String FNT_JA_Pan24x48S = "CZ-8PC4 半角 24x48 サンセリフ体";
715: public static final String FNT_JA_Zen48x48M = "全角 漢字 48x48 明朝体";
716: public static final String FNT_JA_Pic36x46R = "CZ-8PC4 パイカ 36x46 ローマン体";
717: public static final String FNT_JA_Eli30x46R = "CZ-8PC4 エリート 30x46 ローマン体";
718: public static final String FNT_JA_Sma18x46R = "CZ-8PC4 縮小 18x46 ローマン体";
719: public static final String FNT_JA_Scr28x32R = "CZ-8PC4 スクリプト 28x32 ローマン体";
720: public static final String FNT_JA_Pan24x48R = "CZ-8PC4 半角 24x48 ローマン体";
721:
722:
723: public static FontPage.Zen fntPageZen48x48G;
724: public static FontPage.Prn fntPagePic36x46S;
725: public static FontPage.Prn fntPageEli30x46S;
726: public static FontPage.Prn fntPageSma18x46S;
727: public static FontPage.Prn fntPageScr28x32S;
728: public static FontPage.Prn fntPagePan24x48S;
729: public static FontPage.Zen fntPageZen48x48M;
730: public static FontPage.Prn fntPagePic36x46R;
731: public static FontPage.Prn fntPageEli30x46R;
732: public static FontPage.Prn fntPageSma18x46R;
733: public static FontPage.Prn fntPageScr28x32R;
734: public static FontPage.Prn fntPagePan24x48R;
735:
736:
737: public static final String[] FNT_GOTHIC_FAMILIES = {
738:
739: "MS ゴシック", "MS Gothic",
740: "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN",
741: "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro",
742: "Osaka-等幅", "Osaka-Mono",
743: "VL ゴシック", "VL Gothic",
744: "Takaoゴシック", "TakaoGothic",
745: "IPAゴシック", "IPAGothic",
746: };
747: public static final String[] FNT_MINCHO_FAMILIES = {
748:
749: "MS 明朝", "MS Mincho",
750: "ヒラギノ明朝 ProN W3", "Hiragino Mincho ProN",
751: "ヒラギノ明朝 Pro W3", "Hiragino Mincho Pro",
752: "さざなみ明朝", "Sazanami Mincho",
753: "Takao明朝", "TakaoMincho",
754: "IPA明朝", "IPAMincho",
755: };
756: public static String[] fntAvailableFamilies;
757: public static String fntGothicFamily;
758: public static String fntMinchoFamily;
759:
760:
761:
762:
763: public static void prnInit () {
764:
765:
766: fntPageZen48x48G = new FontPage.Zen (48, 48, FNT_EN_Zen48x48G, FNT_JA_Zen48x48G, "./zen48x48g.f48", "./zen48x48g.png");
767: fntPagePic36x46S = new FontPage.Prn (36, 46, FNT_EN_Pic36x46S, FNT_JA_Pic36x46S, "./pic36x46s.dat", "./pic36x46s.png");
768: fntPageEli30x46S = new FontPage.Prn (30, 46, FNT_EN_Eli30x46S, FNT_JA_Eli30x46S, "./eli30x46s.dat", "./eli30x46s.png");
769: fntPageSma18x46S = new FontPage.Prn (18, 46, FNT_EN_Sma18x46S, FNT_JA_Sma18x46S, "./sma18x46s.dat", "./sma18x46s.png");
770: fntPageScr28x32S = new FontPage.Prn (28, 32, FNT_EN_Scr28x32S, FNT_JA_Scr28x32S, "./scr28x32s.dat", "./scr28x32s.png");
771: fntPagePan24x48S = new FontPage.Prn (24, 48, FNT_EN_Pan24x48S, FNT_JA_Pan24x48S, "./pan24x48s.dat", "./pan24x48s.png");
772: fntPageZen48x48M = new FontPage.Zen (48, 48, FNT_EN_Zen48x48M, FNT_JA_Zen48x48M, "./zen48x48m.f48", "./zen48x48m.png");
773: fntPagePic36x46R = new FontPage.Prn (36, 46, FNT_EN_Pic36x46R, FNT_JA_Pic36x46R, "./pic36x46r.dat", "./pic36x46r.png");
774: fntPageEli30x46R = new FontPage.Prn (30, 46, FNT_EN_Eli30x46R, FNT_JA_Eli30x46R, "./eli30x46r.dat", "./eli30x46r.png");
775: fntPageSma18x46R = new FontPage.Prn (18, 46, FNT_EN_Sma18x46R, FNT_JA_Sma18x46R, "./sma18x46r.dat", "./sma18x46r.png");
776: fntPageScr28x32R = new FontPage.Prn (28, 32, FNT_EN_Scr28x32R, FNT_JA_Scr28x32R, "./scr28x32r.dat", "./scr28x32r.png");
777: fntPagePan24x48R = new FontPage.Prn (24, 48, FNT_EN_Pan24x48R, FNT_JA_Pan24x48R, "./pan24x48r.dat", "./pan24x48r.png");
778:
779:
780: prnImageColorModel = new IndexColorModel (
781: 8, 8,
782: new byte[] { 0, 0, 0, 0, -1, -1, -1, -1 },
783: new byte[] { 0, 0, -1, -1, 0, 0, -1, -1 },
784: new byte[] { 0, -1, 0, -1, 0, -1, 0, -1 }
785: );
786: prnDarkImageColorModel = new IndexColorModel (
787: 8, 8,
788: new byte[] { -1, 0, 0, 0, -1, -1, -1, 0 },
789: new byte[] { -1, 0, -1, -1, 0, 0, -1, 0 },
790: new byte[] { -1, -1, 0, -1, 0, -1, 0, 0 }
791: );
792:
793:
794: prnPaperArray = new Paper[] {
795:
796: new Paper (PRN_A_SERIES, 3, PRN_PORTRAIT),
797: new Paper (PRN_A_SERIES, 4, PRN_PORTRAIT),
798: new Paper (PRN_A_SERIES, 5, PRN_PORTRAIT),
799: new Paper (PRN_A_SERIES, 6, PRN_PORTRAIT),
800: new Paper (PRN_B_SERIES, 3, PRN_PORTRAIT),
801: new Paper (PRN_B_SERIES, 4, PRN_PORTRAIT),
802: new Paper (PRN_B_SERIES, 5, PRN_PORTRAIT),
803: new Paper (PRN_B_SERIES, 6, PRN_PORTRAIT),
804: new Paper (PRN_POSTCARD, 0, PRN_PORTRAIT),
805:
806: new Paper (PRN_A_SERIES, 3, PRN_LANDSCAPE),
807: new Paper (PRN_A_SERIES, 4, PRN_LANDSCAPE),
808: new Paper (PRN_A_SERIES, 5, PRN_LANDSCAPE),
809: new Paper (PRN_A_SERIES, 6, PRN_LANDSCAPE),
810: new Paper (PRN_B_SERIES, 3, PRN_LANDSCAPE),
811: new Paper (PRN_B_SERIES, 4, PRN_LANDSCAPE),
812: new Paper (PRN_B_SERIES, 5, PRN_LANDSCAPE),
813: new Paper (PRN_B_SERIES, 6, PRN_LANDSCAPE),
814: new Paper (PRN_POSTCARD, 0, PRN_LANDSCAPE),
815: };
816:
817:
818:
819: prnAutosaveOn = Settings.sgsGetOnOff ("prnauto");
820:
821: prnSavePath = Settings.sgsGetString ("prnpath");
822:
823: prnDIPSW = Settings.sgsGetInt ("prndipsw") & PRN_DIPSW_MASK;
824:
825: String size = Settings.sgsGetString ("prnsize");
826: String orientation = Settings.sgsGetString ("prnorientation");
827: prnNextPaper = prnPaperArray[1];
828: for (Paper paper : prnPaperArray) {
829: if (size.equalsIgnoreCase (paper.sizeEn) &&
830: orientation.equalsIgnoreCase (paper.orientationEn)) {
831: prnNextPaper = paper;
832: break;
833: }
834: }
835: prnCurrentPaper = null;
836:
837: prnNextDeadTopMm = Math.max (0, Math.min (Settings.sgsGetInt ("prntopmargin"), prnNextPaper.paperHeightMm - 1));
838: prnNextDeadLeftMm = Math.max (0, Math.min (Settings.sgsGetInt ("prnleftmargin"), prnNextPaper.paperWidthMm - 1));
839: prnNextDeadRightMm = Math.max (0, Math.min (Settings.sgsGetInt ("prnrightmargin"), prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm));
840: prnNextDeadBottomMm = Math.max (0, Math.min (Settings.sgsGetInt ("prnbottommargin"), prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm));
841:
842: prnNextRotation = Math.max (0, Math.min (Settings.sgsGetInt ("prnrotation"), 3));
843: prnRotation = 0;
844: prnRotatedWidthDot = 0;
845: prnRotatedHeightDot = 0;
846: prnM11 = 0;
847: prnM12 = 0;
848: prnM13 = 0;
849: prnM21 = 0;
850: prnM22 = 0;
851: prnM23 = 0;
852: prnIncrementX = 0;
853: prnIncrementY = 0;
854:
855: prnNextDarkMode = Settings.sgsGetOnOff ("prndarkmode");
856: prnDarkMode = false;
857:
858: prnOnlineOn = Settings.sgsGetOnOff ("prnonline");
859:
860: prnSingleColor = Math.max (0, Math.min (Settings.sgsGetInt ("prnsinglecolor"), 7));
861:
862: prnScaleShift = Math.max (-4, Math.min (Settings.sgsGetInt ("prnscalefactor"), 4));
863:
864:
865: prnReset ();
866:
867:
868: if (PRN_USE_ADAPTER) {
869: prnAdapterInit ();
870: }
871:
872:
873: prnImage = null;
874: prnBitmap = null;
875:
876:
877: prnPrinted = false;
878:
879:
880: prnResetSettings ();
881:
882:
883: prnSaveName = "1.png";
884:
885: }
886:
887:
888: public static void prnTini () {
889:
890:
891:
892: Settings.sgsPutOnOff ("prnauto", prnAutosaveOn);
893:
894: Settings.sgsPutString ("prnpath", prnSavePath);
895:
896: Settings.sgsPutInt ("prndipsw", prnDIPSW);
897:
898: Settings.sgsPutString ("prnsize", prnNextPaper.sizeEn);
899: Settings.sgsPutString ("prnorientation", prnNextPaper.orientationEn);
900: Settings.sgsPutInt ("prntopmargin", prnNextDeadTopMm);
901: Settings.sgsPutInt ("prnleftmargin", prnNextDeadLeftMm);
902: Settings.sgsPutInt ("prnrightmargin", prnNextDeadRightMm);
903: Settings.sgsPutInt ("prnbottommargin", prnNextDeadBottomMm);
904:
905: Settings.sgsPutInt ("prnrotation", prnNextRotation);
906:
907: Settings.sgsPutOnOff ("prndarkmode", prnNextDarkMode);
908:
909: Settings.sgsPutOnOff ("prnonline", prnOnlineOn);
910:
911: Settings.sgsPutInt ("prnsinglecolor", prnSingleColor);
912:
913: Settings.sgsPutInt ("prnscalefactor", prnScaleShift);
914:
915:
916: if (PRN_USE_ADAPTER) {
917: prnAdapterTimer.cancel ();
918: }
919:
920: }
921:
922:
923:
924: public static String[] fntGetAvailableFamilies () {
925: if (fntAvailableFamilies == null) {
926:
927: fntAvailableFamilies = GraphicsEnvironment.getLocalGraphicsEnvironment ().getAvailableFontFamilyNames ();
928: Arrays.sort (fntAvailableFamilies, null);
929: }
930: return fntAvailableFamilies;
931: }
932:
933:
934: public static String fntGetGothicFamily () {
935: if (fntGothicFamily == null) {
936: fntGothicFamily = "Monospaced";
937:
938: String[] availableFamilies = fntGetAvailableFamilies ();
939: for (String family : FNT_GOTHIC_FAMILIES) {
940: if (0 <= Arrays.binarySearch (availableFamilies, family, null)) {
941: fntGothicFamily = family;
942: break;
943: }
944: }
945: System.out.println ((Multilingual.mlnJapanese ? "ゴシック体のフォント: " : "Gothic font: ") + fntGothicFamily);
946: }
947: return fntGothicFamily;
948: }
949:
950:
951: public static String fntGetMinchoFamily () {
952: if (fntMinchoFamily == null) {
953: fntMinchoFamily = "Monospaced";
954:
955: String[] availableFamilies = fntGetAvailableFamilies ();
956: for (String family : FNT_MINCHO_FAMILIES) {
957: if (0 <= Arrays.binarySearch (availableFamilies, family, null)) {
958: fntMinchoFamily = family;
959: break;
960: }
961: }
962: System.out.println ((Multilingual.mlnJapanese ? "明朝体のフォント: " : "Mincho font: ") + fntMinchoFamily);
963: }
964: return fntMinchoFamily;
965: }
966:
967:
968:
969:
970: public static byte[] prnGetGaijiData () {
971: if (prnGaijiData == null) {
972: prnGaijiData = new byte[6 * 48 * 100];
973: }
974: return prnGaijiData;
975: }
976:
977:
978: public static void prnStart () {
979: if (RestorableFrame.rfmGetOpened (Settings.SGS_PRN_FRAME_KEY)) {
980: prnOpen ();
981: }
982: }
983:
984:
985:
986: public static void prnOpen () {
987: if (prnFrame == null) {
988: prnMakeFrame ();
989: }
990: XEiJ.pnlExitFullScreen (false);
991: prnFrame.setVisible (true);
992: }
993:
994:
995:
996:
997: public static void prnMakeFrame () {
998:
999:
1000: prnCanvas = new ScrollCanvas (prnImage);
1001: prnCanvas.setMargin (10, 10);
1002: prnCanvas.setMatColor (new Color (LnF.lnfRGB[4]));
1003:
1004:
1005: ActionListener listener = new ActionListener () {
1006: @Override public void actionPerformed (ActionEvent ae) {
1007: Object source = ae.getSource ();
1008: String command = ae.getActionCommand ();
1009: switch (command) {
1010: case "Online":
1011: prnSetOnlineOn (((JCheckBoxMenuItem) source).isSelected ());
1012: break;
1013: case "Eject":
1014: if (PRN_USE_ADAPTER) {
1015:
1016: prnAdapterTimer.schedule (new PrinterAdapterTask (new byte[] { 0x1a, 0x0c }), 0L);
1017: }
1018: break;
1019: case "Destroy":
1020: if (PRN_USE_ADAPTER) {
1021:
1022: prnAdapterTimer.schedule (new PrinterAdapterTask (new byte[] { 0x1a, 0x1a, 0x1a, 0x0c }), 0L);
1023: }
1024: break;
1025: case "Reset":
1026: if (PRN_USE_ADAPTER) {
1027:
1028: prnAdapterTimer.schedule (new PrinterAdapterTask (new byte[] { 0x1a, 0x1a, 0x1b, 'c', '1' }), 0L);
1029: }
1030: break;
1031: case "Autosave":
1032: prnSetAutosaveOn (((JCheckBoxMenuItem) source).isSelected ());
1033: break;
1034: case "Close":
1035: prnFrame.setVisible (false);
1036: break;
1037:
1038: case "No margins":
1039: prnNextDeadTopMm = 0;
1040: prnNextDeadLeftMm = 0;
1041: prnNextDeadRightMm = 0;
1042: prnNextDeadBottomMm = 0;
1043: prnSpinnerLocked++;
1044: prnDeadTopModel.setValue (Integer.valueOf (prnNextDeadTopMm));
1045: prnDeadLeftModel.setValue (Integer.valueOf (prnNextDeadLeftMm));
1046: prnDeadRightModel.setValue (Integer.valueOf (prnNextDeadRightMm));
1047: prnDeadBottomModel.setValue (Integer.valueOf (prnNextDeadBottomMm));
1048: prnSpinnerLocked--;
1049: break;
1050: case "Reset margins":
1051: prnNextDeadTopMm = prnNextPaper.initialDeadTopMm;
1052: prnNextDeadLeftMm = prnNextPaper.initialDeadLeftMm;
1053: prnNextDeadRightMm = prnNextPaper.initialDeadRightMm;
1054: prnNextDeadBottomMm = prnNextPaper.initialDeadBottomMm;
1055: prnSpinnerLocked++;
1056: prnDeadTopModel.setValue (Integer.valueOf (prnNextDeadTopMm));
1057: prnDeadLeftModel.setValue (Integer.valueOf (prnNextDeadLeftMm));
1058: prnDeadRightModel.setValue (Integer.valueOf (prnNextDeadRightMm));
1059: prnDeadBottomModel.setValue (Integer.valueOf (prnNextDeadBottomMm));
1060: prnSpinnerLocked--;
1061: break;
1062: case "0°":
1063: prnNextRotation = 0;
1064: break;
1065: case "90°":
1066: prnNextRotation = 1;
1067: break;
1068: case "180°":
1069: prnNextRotation = 2;
1070: break;
1071: case "270°":
1072: prnNextRotation = 3;
1073: break;
1074: case "Dark mode":
1075: prnNextDarkMode = ((JCheckBoxMenuItem) source).isSelected ();
1076: break;
1077:
1078: case "Black ink ribbon":
1079: prnSetSingleColor (0);
1080: break;
1081: case "Blue ink ribbon":
1082: prnSetSingleColor (1);
1083: break;
1084: case "Lime ink ribbon":
1085: prnSetSingleColor (2);
1086: break;
1087: case "Cyan ink ribbon":
1088: prnSetSingleColor (3);
1089: break;
1090: case "Red ink ribbon":
1091: prnSetSingleColor (4);
1092: break;
1093: case "Magenta ink ribbon":
1094: prnSetSingleColor (5);
1095: break;
1096: case "Yellow ink ribbon":
1097: prnSetSingleColor (6);
1098: break;
1099: case "White ink ribbon":
1100: prnSetSingleColor (7);
1101: break;
1102:
1103: case "6.25%":
1104: prnCanvas.setScaleShift (-4);
1105: break;
1106: case "12.5%":
1107: prnCanvas.setScaleShift (-3);
1108: break;
1109: case "25%":
1110: prnCanvas.setScaleShift (-2);
1111: break;
1112: case "50%":
1113: prnCanvas.setScaleShift (-1);
1114: break;
1115: case "100%":
1116: prnCanvas.setScaleShift (0);
1117: break;
1118: case "200%":
1119: prnCanvas.setScaleShift (1);
1120: break;
1121: case "400%":
1122: prnCanvas.setScaleShift (2);
1123: break;
1124: case "800%":
1125: prnCanvas.setScaleShift (3);
1126: break;
1127: case "1600%":
1128: prnCanvas.setScaleShift (4);
1129: break;
1130:
1131: case "Roman / Mincho":
1132: prnDIPSW &= ~PRN_DIPSW_FONT_STYLE;
1133: break;
1134: case "Sans-Serif / Gothic":
1135: prnDIPSW |= PRN_DIPSW_FONT_STYLE;
1136: break;
1137:
1138: default:
1139: for (Paper paper : prnPaperArray) {
1140: if (paper.nameEn.equals (command)) {
1141: prnNextPaper = paper;
1142: prnNextDeadTopMm = Math.min (prnNextDeadTopMm, prnNextPaper.paperHeightMm - 1);
1143: prnNextDeadLeftMm = Math.min (prnNextDeadLeftMm, prnNextPaper.paperWidthMm - 1);
1144: prnNextDeadRightMm = Math.min (prnNextDeadRightMm, prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm);
1145: prnNextDeadBottomMm = Math.min (prnNextDeadBottomMm, prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm);
1146: prnSpinnerLocked++;
1147: prnDeadTopModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1));
1148: prnDeadLeftModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1));
1149: prnDeadRightModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm));
1150: prnDeadBottomModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm));
1151: prnDeadTopModel.setValue (Integer.valueOf (prnNextDeadTopMm));
1152: prnDeadLeftModel.setValue (Integer.valueOf (prnNextDeadLeftMm));
1153: prnDeadRightModel.setValue (Integer.valueOf (prnNextDeadRightMm));
1154: prnDeadBottomModel.setValue (Integer.valueOf (prnNextDeadBottomMm));
1155: prnSpinnerLocked--;
1156: break;
1157: }
1158: }
1159: }
1160: }
1161: };
1162:
1163:
1164: ButtonGroup paperGroup = new ButtonGroup ();
1165: JMenu portraitMenu = Multilingual.mlnText (ComponentFactory.createMenu ("Portrait", 'P'), "ja", "縦長");
1166: JMenu landscapeMenu = Multilingual.mlnText (ComponentFactory.createMenu ("Landscape", 'L'), "ja", "横長");
1167: for (int i = 0; i < prnPaperArray.length; i++) {
1168: Paper paper = prnPaperArray[i];
1169: (i < prnPaperArray.length >> 1 ? portraitMenu : landscapeMenu).add (
1170: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (
1171: paperGroup, paper == prnNextPaper, paper.nameEn, listener), "ja", paper.nameJa));
1172: }
1173:
1174: prnSpinnerLocked = 0;
1175: prnDeadTopModel = new SpinnerNumberModel (prnNextDeadTopMm, 0, prnNextPaper.paperHeightMm - 1, 1);
1176: prnDeadLeftModel = new SpinnerNumberModel (prnNextDeadLeftMm, 0, prnNextPaper.paperWidthMm - 1, 1);
1177: prnDeadRightModel = new SpinnerNumberModel (prnNextDeadRightMm, 0, prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm, 1);
1178: prnDeadBottomModel = new SpinnerNumberModel (prnNextDeadBottomMm, 0, prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm, 1);
1179: prnDeadTopSpinner = ComponentFactory.createNumberSpinner (prnDeadTopModel, 4, new ChangeListener () {
1180: @Override public void stateChanged (ChangeEvent ce) {
1181: if (prnSpinnerLocked == 0) {
1182: prnNextDeadTopMm = prnDeadTopModel.getNumber ().intValue ();
1183: prnDeadBottomModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm));
1184: }
1185: }
1186: });
1187: prnDeadLeftSpinner = ComponentFactory.createNumberSpinner (prnDeadLeftModel, 4, new ChangeListener () {
1188: @Override public void stateChanged (ChangeEvent ce) {
1189: if (prnSpinnerLocked == 0) {
1190: prnNextDeadLeftMm = prnDeadLeftModel.getNumber ().intValue ();
1191: prnDeadRightModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm));
1192: }
1193: }
1194: });
1195: prnDeadRightSpinner = ComponentFactory.createNumberSpinner (prnDeadRightModel, 4, new ChangeListener () {
1196: @Override public void stateChanged (ChangeEvent ce) {
1197: if (prnSpinnerLocked == 0) {
1198: prnNextDeadRightMm = prnDeadRightModel.getNumber ().intValue ();
1199: prnDeadLeftModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1 - prnNextDeadRightMm));
1200: }
1201: }
1202: });
1203: prnDeadBottomSpinner = ComponentFactory.createNumberSpinner (prnDeadBottomModel, 4, new ChangeListener () {
1204: @Override public void stateChanged (ChangeEvent ce) {
1205: if (prnSpinnerLocked == 0) {
1206: prnNextDeadBottomMm = prnDeadBottomModel.getNumber ().intValue ();
1207: prnDeadTopModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1 - prnNextDeadBottomMm));
1208: }
1209: }
1210: });
1211:
1212:
1213: ButtonGroup ribbonGroup = new ButtonGroup ();
1214:
1215:
1216: ButtonGroup zoomGroup = new ButtonGroup ();
1217: prnScaleMenuItem = new JRadioButtonMenuItem[9];
1218: ButtonGroup directionGroup = new ButtonGroup ();
1219: ButtonGroup fontStyleGroup = new ButtonGroup ();
1220:
1221:
1222: JMenuBar menuBar = ComponentFactory.createMenuBar (
1223:
1224:
1225: Multilingual.mlnText (
1226: ComponentFactory.createMenu (
1227: "File", 'F',
1228: prnOnlineMenuItem =
1229: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (prnOnlineOn, "Online", listener), "ja", "オンライン"),
1230: ComponentFactory.createHorizontalSeparator (),
1231: !PRN_USE_ADAPTER ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("Eject", 'E', listener), "ja", "排紙"),
1232: !PRN_USE_ADAPTER ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("Destroy", 'D', listener), "ja", "破棄"),
1233: !PRN_USE_ADAPTER ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', listener), "ja", "リセット"),
1234: ComponentFactory.createHorizontalSeparator (),
1235: prnAutosaveMenuItem =
1236: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (prnAutosaveOn, "Autosave", listener), "ja", "自動保存"),
1237: ComponentFactory.createHorizontalSeparator (),
1238: Multilingual.mlnText (ComponentFactory.createMenuItem ("Close", 'C', listener), "ja", "閉じる")
1239: ),
1240: "ja", "ファイル"),
1241:
1242:
1243: Multilingual.mlnText (
1244: ComponentFactory.createMenu (
1245: "Paper", 'P',
1246: portraitMenu,
1247: landscapeMenu,
1248: ComponentFactory.createHorizontalSeparator (),
1249: Multilingual.mlnText (
1250: ComponentFactory.createMenu (
1251: "Margin", 'M',
1252: ComponentFactory.createHorizontalBox (
1253: Box.createHorizontalGlue (),
1254: Multilingual.mlnText (ComponentFactory.createLabel ("Top "), "ja", "上 "),
1255: prnDeadTopSpinner,
1256: ComponentFactory.createLabel (" mm"),
1257: Box.createHorizontalGlue ()
1258: ),
1259: ComponentFactory.createHorizontalBox (
1260: Box.createHorizontalGlue (),
1261: Multilingual.mlnText (ComponentFactory.createLabel ("Left "), "ja", "左 "),
1262: prnDeadLeftSpinner,
1263: ComponentFactory.createLabel (" mm"),
1264: Box.createHorizontalStrut (20),
1265: Multilingual.mlnText (ComponentFactory.createLabel ("Right "), "ja", "右 "),
1266: prnDeadRightSpinner,
1267: ComponentFactory.createLabel (" mm"),
1268: Box.createHorizontalGlue ()
1269: ),
1270: ComponentFactory.createHorizontalBox (
1271: Box.createHorizontalGlue (),
1272: Multilingual.mlnText (ComponentFactory.createLabel ("Bottom "), "ja", "下 "),
1273: prnDeadBottomSpinner,
1274: ComponentFactory.createLabel (" mm"),
1275: Box.createHorizontalGlue ()
1276: ),
1277: ComponentFactory.createHorizontalSeparator (),
1278: Multilingual.mlnText (ComponentFactory.createMenuItem ("No margins", listener), "ja", "余白なし"),
1279: ComponentFactory.createHorizontalSeparator (),
1280: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset margins", listener), "ja", "初期値に戻す")
1281: ),
1282: "ja", "余白"),
1283: ComponentFactory.createHorizontalSeparator (),
1284: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 0, "0°", listener),
1285: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 1, "90°", listener),
1286: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 2, "180°", listener),
1287: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 3, "270°", listener),
1288: ComponentFactory.createHorizontalSeparator (),
1289: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (prnNextDarkMode, "Dark mode", listener), "ja", "ダークモード")
1290: ),
1291: "ja", "用紙"),
1292:
1293:
1294: Multilingual.mlnText (
1295: ComponentFactory.createMenu (
1296: "Ink ribbon", 'R',
1297: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 0,
1298: "Black ink ribbon", '0', listener),
1299: "ja", "黒色インクリボン"),
1300: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 1,
1301: "Blue ink ribbon", '1', listener),
1302: "ja", "青色インクリボン"),
1303: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 2,
1304: "Lime ink ribbon", '2', listener),
1305: "ja", "緑色インクリボン"),
1306: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 3,
1307: "Cyan ink ribbon", '3', listener),
1308: "ja", "水色インクリボン"),
1309: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 4,
1310: "Red ink ribbon", '4', listener),
1311: "ja", "赤色インクリボン"),
1312: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 5,
1313: "Magenta ink ribbon", '5', listener),
1314: "ja", "紫色インクリボン"),
1315: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 6,
1316: "Yellow ink ribbon", '6', listener),
1317: "ja", "黄色インクリボン"),
1318: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 7,
1319: "White ink ribbon", '7', listener),
1320: "ja", "白色インクリボン")
1321: ),
1322: "ja", "インクリボン"),
1323:
1324:
1325: Multilingual.mlnText (
1326: ComponentFactory.createMenu (
1327: "Display", 'D',
1328: prnScaleMenuItem[0] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -4, "6.25%", '1', listener),
1329: prnScaleMenuItem[1] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -3, "12.5%", '2', listener),
1330: prnScaleMenuItem[2] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -2, "25%", '3', listener),
1331: prnScaleMenuItem[3] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -1, "50%", '4', listener),
1332: prnScaleMenuItem[4] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 0, "100%", '5', listener),
1333: prnScaleMenuItem[5] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 1, "200%", '6', listener),
1334: prnScaleMenuItem[6] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 2, "400%", '7', listener),
1335: prnScaleMenuItem[7] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 3, "800%", '8', listener),
1336: prnScaleMenuItem[8] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 4, "1600%", '9', listener)
1337: ),
1338: "ja", "表示"),
1339:
1340:
1341: ComponentFactory.createMenu (
1342: "DIPSW", 'S',
1343: Multilingual.mlnText (
1344: ComponentFactory.createRadioButtonMenuItem (
1345: fontStyleGroup,
1346: (prnDIPSW & PRN_DIPSW_FONT_STYLE) == 0,
1347: "Roman / Mincho",
1348: listener
1349: ),
1350: "ja", "ローマン体/明朝体"
1351: ),
1352: Multilingual.mlnText (
1353: ComponentFactory.createRadioButtonMenuItem (
1354: fontStyleGroup,
1355: (prnDIPSW & PRN_DIPSW_FONT_STYLE) != 0,
1356: "Sans-Serif / Gothic",
1357: listener
1358: ),
1359: "ja", "サンセリフ体/ゴシック体"
1360: )
1361: )
1362:
1363: );
1364:
1365:
1366: prnCanvas.addScaleShiftListener (new ScrollCanvas.ScaleShiftListener () {
1367: @Override public void scaleShiftChanged (int scaleShift) {
1368: if (prnScaleShift != scaleShift &&
1369: -4 <= scaleShift && scaleShift <= 4) {
1370: prnScaleShift = scaleShift;
1371: prnScaleMenuItem[4 + scaleShift].setSelected (true);
1372: }
1373: }
1374: });
1375:
1376:
1377: prnFrame = Multilingual.mlnTitle (
1378: ComponentFactory.createRestorableSubFrame (
1379: Settings.SGS_PRN_FRAME_KEY,
1380: "Printer",
1381: menuBar,
1382: ComponentFactory.createBorderPanel (
1383: ComponentFactory.setPreferredSize (prnCanvas, 600, 400),
1384: null,
1385: null,
1386: null
1387: )
1388: ),
1389: "ja", "プリンタ");
1390:
1391: }
1392:
1393:
1394:
1395: public static void prnMakeSaveDialog () {
1396:
1397: prnWriterSuffixes = ImageIO.getWriterFileSuffixes ();
1398: if (XEiJ.prgCaseIgnored) {
1399: for (int i = 0; i < prnWriterSuffixes.length; i++) {
1400: prnWriterSuffixes[i] = prnWriterSuffixes[i].toLowerCase ();
1401: }
1402: }
1403:
1404: prnSaveFileFilter = new javax.swing.filechooser.FileFilter () {
1405: @Override public boolean accept (File file) {
1406: if (file.isDirectory ()) {
1407: return true;
1408: }
1409: String name = file.getName ();
1410: if (XEiJ.prgCaseIgnored) {
1411: name = name.toLowerCase ();
1412: }
1413: for (String suffix : prnWriterSuffixes) {
1414: if (name.endsWith ("." + suffix)) {
1415: return true;
1416: }
1417: }
1418: return false;
1419: }
1420: @Override public String getDescription () {
1421: return Multilingual.mlnJapanese ? "プリンタ出力イメージ" : "Printer Output Image";
1422: }
1423: };
1424:
1425: ActionListener listener = new ActionListener () {
1426: @Override public void actionPerformed (ActionEvent ae) {
1427: switch (ae.getActionCommand ()) {
1428: case JFileChooser.APPROVE_SELECTION:
1429: case "Save":
1430: {
1431: File file = prnSaveFileChooser.getSelectedFile ().getAbsoluteFile ();
1432: prnSavePath = file.getParentFile ().getAbsolutePath ();
1433: prnSaveName = file.getName ();
1434: }
1435: if (prnSave ()) {
1436:
1437:
1438: prnSaveDialog.setVisible (false);
1439: }
1440: break;
1441: case JFileChooser.CANCEL_SELECTION:
1442: case "Discard":
1443: prnSaveDialog.setVisible (false);
1444: break;
1445: case "Autosave from next time":
1446: prnSetAutosaveOn (prnAutosaveCheckBox.isSelected ());
1447: break;
1448: }
1449: }
1450: };
1451:
1452: prnSaveFileChooser = new JFileChooser2 (new File (prnSavePath + File.separator + prnSaveName));
1453: prnSaveFileChooser.setFileFilter (prnSaveFileFilter);
1454: prnSaveFileChooser.setMultiSelectionEnabled (false);
1455: prnSaveFileChooser.setControlButtonsAreShown (false);
1456: prnSaveFileChooser.addActionListener (listener);
1457:
1458: prnSaveDialog = Multilingual.mlnTitle (
1459: ComponentFactory.createModalDialog (
1460: XEiJ.frmFrame,
1461: "Save printer output image",
1462: ComponentFactory.createBorderPanel (
1463: 0, 0,
1464: ComponentFactory.createVerticalBox (
1465: prnSaveFileChooser,
1466: ComponentFactory.createHorizontalBox (
1467: Box.createHorizontalStrut (12),
1468: Box.createHorizontalGlue (),
1469: prnAutosaveCheckBox =
1470: Multilingual.mlnText (ComponentFactory.createCheckBox (prnAutosaveOn, "Autosave from next time", listener), "ja", "次回から自動保存"),
1471: Box.createHorizontalGlue (),
1472: Box.createHorizontalStrut (12),
1473: Multilingual.mlnText (ComponentFactory.createButton ("Save", KeyEvent.VK_S, listener), "ja", "保存"),
1474: Box.createHorizontalStrut (12),
1475: Multilingual.mlnText (ComponentFactory.createButton ("Discard", KeyEvent.VK_D, listener), "ja", "破棄"),
1476: Box.createHorizontalStrut (12)
1477: ),
1478: Box.createVerticalStrut (12)
1479: )
1480: )
1481: ),
1482: "ja", "プリンタ出力イメージの保存");
1483: }
1484:
1485:
1486:
1487: public static void prnSetAutosaveOn (boolean on) {
1488: if (prnAutosaveOn != on) {
1489: prnAutosaveOn = on;
1490: if (prnAutosaveCheckBox != null &&
1491: prnAutosaveCheckBox.isSelected () != prnAutosaveOn) {
1492: prnAutosaveCheckBox.setSelected (prnAutosaveOn);
1493: }
1494: if (prnAutosaveMenuItem != null &&
1495: prnAutosaveMenuItem.isSelected () != prnAutosaveOn) {
1496: prnAutosaveMenuItem.setSelected (prnAutosaveOn);
1497: }
1498: }
1499: }
1500:
1501:
1502:
1503:
1504:
1505:
1506:
1507: public static void prnReset () {
1508: prnData = 0;
1509: prnStrobe = 1;
1510: }
1511:
1512:
1513: public static int prnReadData () {
1514: return prnData;
1515: }
1516:
1517:
1518: public static int prnReadStrobe () {
1519: return prnStrobe;
1520: }
1521:
1522:
1523: public static void prnWriteData (int d) {
1524: prnData = d & 255;
1525: }
1526:
1527:
1528: public static void prnWriteStrobe (int d) {
1529: d &= 1;
1530: if (prnStrobe != d) {
1531: prnStrobe = d;
1532: if (prnOnlineOn) {
1533: if (d != 0) {
1534:
1535: IOInterrupt.ioiPrnFall ();
1536:
1537: if (PRN_USE_ADAPTER) {
1538: prnAdapterOutput (prnData);
1539: } else {
1540: prnOutput (prnData);
1541: }
1542:
1543: IOInterrupt.ioiPrnRise ();
1544: }
1545: }
1546: }
1547: }
1548:
1549:
1550:
1551: public static void prnSetOnlineOn (boolean on) {
1552: if (prnOnlineOn != on) {
1553: prnOnlineOn = on;
1554: if (prnOnlineMenuItem != null) {
1555: prnOnlineMenuItem.setSelected (on);
1556: }
1557: if (on) {
1558:
1559: IOInterrupt.ioiPrnRise ();
1560: } else {
1561:
1562: IOInterrupt.ioiPrnFall ();
1563: }
1564: }
1565: }
1566:
1567:
1568:
1569:
1570:
1571:
1572:
1573:
1574: public static void prnOutput (int x) {
1575: prnCommandBuffer[prnCommandPointer++] = (byte) x;
1576: if (prnCommandPointer < prnCommandLength) {
1577: return;
1578: }
1579: command:
1580: {
1581: int c = prnCommandBuffer[0] & 255;
1582: int d, e, f, g, h, i, j, z, n;
1583: switch (c) {
1584: case 0x08:
1585: prnPrintBackSpace ();
1586: break command;
1587: case 0x09:
1588: prnPrintHorizontalTab ();
1589: break command;
1590: case 0x0a:
1591: prnPrintLineFeed (1);
1592: break command;
1593: case 0x0b:
1594: if (prnCommandLength < 2) {
1595: prnCommandLength = 2;
1596: return;
1597: }
1598: d = prnCommandBuffer[1] & 255;
1599: prnPrintVerticalTab (d & 15);
1600: break command;
1601: case 0x0c:
1602: prnPrintFormFeed ();
1603: break command;
1604: case 0x0d:
1605: prnPrintCarriageReturn ();
1606: break command;
1607: case 0x0e:
1608: prnSetHorizontalDoubleSizeMode (true);
1609: break command;
1610: case 0x0f:
1611: prnSetHorizontalDoubleSizeMode (false);
1612: break command;
1613: case 0x10:
1614: if (prnCommandLength < 4) {
1615: prnCommandLength = 4;
1616: return;
1617: }
1618: d = prnCommandBuffer[1] & 255;
1619: e = prnCommandBuffer[2] & 255;
1620: f = prnCommandBuffer[3] & 255;
1621: prnSetStartColumn ((d & 15) * 100 + (e & 15) * 10 + (f & 15));
1622: break command;
1623: case 0x11:
1624: prnSelect (true);
1625: break command;
1626: case 0x13:
1627: prnSelect (false);
1628: break command;
1629: case 0x14:
1630: z = prnCommandBuffer[prnCommandLength - 1] & 255;
1631: if (z != 0x3f) {
1632: if (prnCommandLength + 1 < prnCommandBuffer.length) {
1633: prnCommandLength++;
1634: }
1635: return;
1636: }
1637: prnSetVerticalTabAnchor (prnCommandBuffer, 1, prnCommandLength - 1);
1638: break command;
1639: case 0x18:
1640: prnCancel ();
1641: break command;
1642: case 0x1a:
1643: if (prnCommandLength < 2) {
1644: prnCommandLength = 2;
1645: return;
1646: }
1647: d = prnCommandBuffer[1] & 255;
1648: switch (d) {
1649: case 0x0c:
1650: prnEjectPaper ();
1651: break command;
1652: case 0x1a:
1653: prnErasePaper ();
1654: break command;
1655: case 0x56:
1656: prnSetVerticalDoubleSizeMode (true);
1657: break command;
1658: case 0x57:
1659: prnSetVerticalDoubleSizeMode (false);
1660: break command;
1661: }
1662: break;
1663: case 0x1b:
1664: if (prnCommandLength < 2) {
1665: prnCommandLength = 2;
1666: return;
1667: }
1668: d = prnCommandBuffer[1] & 255;
1669: switch (d) {
1670: case 0x00:
1671: case 0x01:
1672: case 0x02:
1673: case 0x03:
1674: case 0x04:
1675: case 0x05:
1676: case 0x06:
1677: prnHorizontalMove (d);
1678: break command;
1679: case 0x0b:
1680: if (prnCommandLength < 4) {
1681: prnCommandLength = 4;
1682: return;
1683: }
1684: e = prnCommandBuffer[2] & 255;
1685: f = prnCommandBuffer[3] & 255;
1686: prnPrintLineFeed ((e & 15) * 10 + (f & 15));
1687: break command;
1688: case 0x10:
1689: if (prnCommandLength < 6) {
1690: prnCommandLength = 6;
1691: return;
1692: }
1693: e = prnCommandBuffer[2] & 255;
1694: f = prnCommandBuffer[3] & 255;
1695: g = prnCommandBuffer[4] & 255;
1696: h = prnCommandBuffer[5] & 255;
1697: prnSetHorizontalStartPosition ((e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15));
1698: break command;
1699: case 0x19:
1700: prnSetColorMode ();
1701: break command;
1702: case 0x21:
1703: prnSetStrongMode (true);
1704: break command;
1705: case 0x22:
1706: prnSetStrongMode (false);
1707: break command;
1708: case 0x24:
1709: prnSetHiraganaMode (false);
1710: break command;
1711: case 0x25:
1712: if (prnCommandLength < 3) {
1713: prnCommandLength = 3;
1714: return;
1715: }
1716: e = prnCommandBuffer[2] & 255;
1717: switch (e) {
1718: case 0x32:
1719: if (prnCommandLength < 5) {
1720: prnCommandLength = 5;
1721: return;
1722: }
1723: f = prnCommandBuffer[3] & 255;
1724: g = prnCommandBuffer[4] & 255;
1725: n = f << 8 | g;
1726: if (prnCommandLength < 5 + n) {
1727: prnCommandLength = 5 + n;
1728: return;
1729: }
1730: prn8DotBitImage (prnCommandBuffer, 5, n);
1731: break command;
1732: case 0x39:
1733: if (prnCommandLength < 4) {
1734: prnCommandLength = 4;
1735: return;
1736: }
1737: f = prnCommandBuffer[3] & 255;
1738: prnSetLineHeight (f);
1739: break command;
1740: }
1741: break;
1742: case 0x26:
1743: prnSetHiraganaMode (true);
1744: break command;
1745: case 0x28:
1746: z = prnCommandBuffer[prnCommandLength - 1] & 255;
1747: if (z != 0x2e) {
1748: if (prnCommandLength + 1 < prnCommandBuffer.length) {
1749: prnCommandLength++;
1750: }
1751: return;
1752: }
1753: prnSetHorizontalTabAnchor (prnCommandBuffer, 2, prnCommandLength - 2);
1754: break command;
1755: case 0x29:
1756: z = prnCommandBuffer[prnCommandLength - 1] & 255;
1757: if (z != 0x2e) {
1758: if (prnCommandLength + 1 < prnCommandBuffer.length) {
1759: prnCommandLength++;
1760: }
1761: return;
1762: }
1763: prnClearHorizontalTabAnchor (prnCommandBuffer, 2, prnCommandLength - 2);
1764: break command;
1765: case 0x2a:
1766: if (prnCommandLength < 36) {
1767: prnCommandLength = 36;
1768: return;
1769: }
1770: prn16DotExtendedCharacterDefinition (prnCommandBuffer, 2, prnCommandLength - 2);
1771: break command;
1772: case 0x2b:
1773: if (prnCommandLength < 76) {
1774: prnCommandLength = 76;
1775: return;
1776: }
1777: prn24DotExtendedCharacterDefinition (prnCommandBuffer, 2, prnCommandLength - 2);
1778: break command;
1779: case 0x2f:
1780: if (prnCommandLength < 5) {
1781: prnCommandLength = 5;
1782: return;
1783: }
1784: e = prnCommandBuffer[2] & 255;
1785: f = prnCommandBuffer[3] & 255;
1786: g = prnCommandBuffer[4] & 255;
1787: prnSetRightMargin ((e & 15) * 100 + (f & 15) * 10 + (g & 15));
1788: break command;
1789: case 0x32:
1790: prnClearAllHorizontalTabAnchor ();
1791: break command;
1792: case 0x35:
1793: prnSetPageStartPosition ();
1794: break command;
1795: case 0x36:
1796: prnSetOneSixth ();
1797: break command;
1798: case 0x38:
1799: prnSetOneEighth ();
1800: break command;
1801: case 0x43:
1802: if (prnCommandLength < 4) {
1803: prnCommandLength = 4;
1804: return;
1805: }
1806: e = prnCommandBuffer[2] & 255;
1807: f = prnCommandBuffer[3] & 255;
1808: prnSetBottomMargin ((e & 15) * 10 + (f & 15));
1809: break command;
1810: case 0x45:
1811: prnSetEliteCharacterMode ();
1812: break command;
1813: case 0x46:
1814: if (prnCommandLength < 4) {
1815: prnCommandLength = 4;
1816: return;
1817: }
1818: e = prnCommandBuffer[2] & 255;
1819: f = prnCommandBuffer[3] & 255;
1820: prnSetPageHeight ((e & 15) * 10 + (f & 15));
1821: break command;
1822: case 0x48:
1823: prnSetKanjiMode (false);
1824: break command;
1825: case 0x49:
1826: if (prnCommandLength < 6) {
1827: prnCommandLength = 6;
1828: return;
1829: }
1830: e = prnCommandBuffer[2] & 255;
1831: f = prnCommandBuffer[3] & 255;
1832: g = prnCommandBuffer[4] & 255;
1833: h = prnCommandBuffer[5] & 255;
1834: n = (e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15);
1835: if (prnCommandLength < 6 + 2 * n) {
1836: prnCommandLength = 6 + 2 * n;
1837: return;
1838: }
1839: prn16DotBitImage (prnCommandBuffer, 6, n);
1840: break command;
1841: case 0x4a:
1842: if (prnCommandLength < 4) {
1843: prnCommandLength = 4;
1844: return;
1845: }
1846: e = prnCommandBuffer[2] & 255;
1847: f = prnCommandBuffer[3] & 255;
1848: n = e << 8 | f;
1849: if (prnCommandLength < 4 + 3 * n) {
1850: prnCommandLength = 4 + 3 * n;
1851: return;
1852: }
1853: prn24DotBitImage (prnCommandBuffer, 4, n);
1854: break command;
1855: case 0x4b:
1856: prnSetKanjiMode (true);
1857: break command;
1858: case 0x4c:
1859: if (prnCommandLength < 5) {
1860: prnCommandLength = 5;
1861: return;
1862: }
1863: e = prnCommandBuffer[2] & 255;
1864: f = prnCommandBuffer[3] & 255;
1865: g = prnCommandBuffer[4] & 255;
1866: prnSetLeftMargin ((e & 15) * 100 + (f & 15) * 10 + (g & 15));
1867: break command;
1868: case 0x4d:
1869: if (prnCommandLength < 4) {
1870: prnCommandLength = 4;
1871: return;
1872: }
1873: e = prnCommandBuffer[2] & 255;
1874: f = prnCommandBuffer[3] & 255;
1875: n = e << 8 | f;
1876: if (prnCommandLength < 4 + 6 * n) {
1877: prnCommandLength = 4 + 6 * n;
1878: return;
1879: }
1880: prn48DotBitImage (prnCommandBuffer, 4, n);
1881: break command;
1882: case 0x4e:
1883: if (prnCommandLength < 6) {
1884: prnCommandLength = 6;
1885: return;
1886: }
1887: e = prnCommandBuffer[2] & 255;
1888: f = prnCommandBuffer[3] & 255;
1889: g = prnCommandBuffer[4] & 255;
1890: h = prnCommandBuffer[5] & 255;
1891: prnRepeatCharacter ((e & 15) * 100 + (f & 15) * 10 + (g & 15), h);
1892: break command;
1893: case 0x50:
1894: prnSetKanjiMode (false);
1895: break command;
1896: case 0x51:
1897: prnSetSmallCharacterMode ();
1898: break command;
1899: case 0x52:
1900: prnSetPicaCharacterMode ();
1901: break command;
1902: case 0x55:
1903: prnSetHorizontalDoubleSizeMode (true);
1904: break command;
1905: case 0x56:
1906: if (prnCommandLength < 7) {
1907: prnCommandLength = 7;
1908: return;
1909: }
1910: e = prnCommandBuffer[2] & 255;
1911: f = prnCommandBuffer[3] & 255;
1912: g = prnCommandBuffer[4] & 255;
1913: h = prnCommandBuffer[5] & 255;
1914: i = prnCommandBuffer[6] & 255;
1915: prnRepeat8DotBitImage ((e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15), i);
1916: break command;
1917: case 0x57:
1918: if (prnCommandLength < 8) {
1919: prnCommandLength = 8;
1920: return;
1921: }
1922: e = prnCommandBuffer[2] & 255;
1923: f = prnCommandBuffer[3] & 255;
1924: g = prnCommandBuffer[4] & 255;
1925: h = prnCommandBuffer[5] & 255;
1926: i = prnCommandBuffer[6] & 255;
1927: j = prnCommandBuffer[7] & 255;
1928: prnRepeat16DotBitImage ((e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15), i << 8 | j);
1929: break command;
1930: case 0x58:
1931: prnSetUnderlineMode (true);
1932: break command;
1933: case 0x59:
1934: prnSetUnderlineMode (false);
1935: break command;
1936: case 0x5c:
1937: if (prnCommandLength < 4) {
1938: prnCommandLength = 4;
1939: return;
1940: }
1941: e = prnCommandBuffer[2] & 255;
1942: f = prnCommandBuffer[3] & 255;
1943: prnHorizontalMove ((short) (f << 8 | e));
1944: break command;
1945: case 0x63:
1946: if (prnCommandLength < 3) {
1947: prnCommandLength = 3;
1948: return;
1949: }
1950: e = prnCommandBuffer[2] & 255;
1951: switch (e) {
1952: case 0x31:
1953: prnResetSettings ();
1954: break command;
1955: }
1956: break;
1957: case 0x6b:
1958: if (prnCommandLength < 3) {
1959: prnCommandLength = 3;
1960: return;
1961: }
1962: e = prnCommandBuffer[2] & 255;
1963: prnSetHalfWidthFont (e);
1964: break command;
1965: case 0x70:
1966: if (prnCommandLength < 3) {
1967: prnCommandLength = 3;
1968: return;
1969: }
1970: e = prnCommandBuffer[2] & 255;
1971: switch (e) {
1972: case 0x30:
1973: prnSenseOutOfPaper (false);
1974: break command;
1975: case 0x31:
1976: prnSenseOutOfPaper (true);
1977: break command;
1978: }
1979: break;
1980: case 0x71:
1981: if (prnCommandLength < 3) {
1982: prnCommandLength = 3;
1983: return;
1984: }
1985: e = prnCommandBuffer[2] & 255;
1986: prnSetCharacterStyle (e);
1987: break command;
1988: case 0x73:
1989: if (prnCommandLength < 3) {
1990: prnCommandLength = 3;
1991: return;
1992: }
1993: e = prnCommandBuffer[2] & 255;
1994: switch (e) {
1995: case 0x30:
1996: prnSetScriptMode (0);
1997: break command;
1998: case 0x31:
1999: prnSetScriptMode (1);
2000: break command;
2001: case 0x32:
2002: prnSetScriptMode (2);
2003: break command;
2004: }
2005: break;
2006: }
2007: break;
2008: case 0x1c:
2009: if (prnCommandLength < 2) {
2010: prnCommandLength = 2;
2011: return;
2012: }
2013: d = prnCommandBuffer[1] & 255;
2014: switch (d) {
2015: case 0x4a:
2016: prnSetVerticalWritingMode (true);
2017: break command;
2018: case 0x4b:
2019: prnSetVerticalWritingMode (false);
2020: break command;
2021: case 0x53:
2022: if (prnCommandLength < 4) {
2023: prnCommandLength = 4;
2024: return;
2025: }
2026: e = prnCommandBuffer[2] & 255;
2027: f = prnCommandBuffer[3] & 255;
2028: prnSetFullWidthLeftRightSpace (e, f);
2029: break command;
2030: case 0x54:
2031: if (prnCommandLength < 4) {
2032: prnCommandLength = 4;
2033: return;
2034: }
2035: e = prnCommandBuffer[2] & 255;
2036: f = prnCommandBuffer[3] & 255;
2037: prnSetHalfWidthLeftRightSpace (e, f);
2038: break command;
2039: case 0x6b:
2040: if (prnCommandLength < 3) {
2041: prnCommandLength = 3;
2042: return;
2043: }
2044: e = prnCommandBuffer[2] & 255;
2045: prnSetFullWidthFont (e);
2046: break command;
2047: case 0x70:
2048: prnSetKanjiHorizontalDoubleSizeMode (true);
2049: break command;
2050: case 0x71:
2051: prnSetKanjiHorizontalDoubleSizeMode (false);
2052: break command;
2053: }
2054: break;
2055: default:
2056: if (prnKanjiMode) {
2057: if (prnCommandLength < 2) {
2058: prnCommandLength = 2;
2059: return;
2060: }
2061: d = prnCommandBuffer[1] & 255;
2062: c = c << 8 | d;
2063: }
2064: if (c != 0) {
2065: prnPrintCharacter (c);
2066: }
2067: break command;
2068: }
2069:
2070: for (int k = 0; k < prnCommandLength; k++) {
2071: prnPrintCharacter (prnCommandBuffer[k] & 255);
2072: }
2073: }
2074:
2075: prnCommandLength = 1;
2076: prnCommandPointer = 0;
2077: }
2078:
2079:
2080:
2081: public static void prnFeedPaper () {
2082: if (prnCurrentPaper != null) {
2083: return;
2084: }
2085:
2086: prnCurrentPaper = prnNextPaper;
2087:
2088: prnDeadTopMm = Math.min (prnNextDeadTopMm, prnCurrentPaper.paperHeightMm - 1);
2089: prnDeadLeftMm = Math.min (prnNextDeadLeftMm, prnCurrentPaper.paperWidthMm - 1);
2090: prnDeadRightMm = Math.min (prnNextDeadRightMm, prnCurrentPaper.paperWidthMm - 1 - prnDeadLeftMm);
2091: prnDeadBottomMm = Math.min (prnNextDeadBottomMm, prnCurrentPaper.paperHeightMm - 1 - prnDeadTopMm);
2092:
2093: prnAliveTopY = (int) Math.floor ((double) prnDeadTopMm * (360.0 / 25.4) + 0.5);
2094: prnAliveLeftX = (int) Math.floor ((double) prnDeadLeftMm * (360.0 / 25.4) + 0.5);
2095: prnAliveRightX = (int) Math.floor ((double) (prnCurrentPaper.paperWidthMm - prnDeadRightMm) * (360.0 / 25.4) + 0.5);
2096: prnAliveBottomY = (int) Math.floor ((double) (prnCurrentPaper.paperHeightMm - prnDeadBottomMm) * (360.0 / 25.4) + 0.5);
2097:
2098: prnRotation = prnNextRotation;
2099: if (prnRotation == 0) {
2100: prnRotatedWidthDot = prnCurrentPaper.paperWidthDot;
2101: prnRotatedHeightDot = prnCurrentPaper.paperHeightDot;
2102:
2103:
2104:
2105: prnM11 = 1;
2106: prnM12 = 0;
2107: prnM13 = 0;
2108: prnM21 = 0;
2109: prnM22 = 1;
2110: prnM23 = 0;
2111: } else if (prnRotation == 1) {
2112: prnRotatedWidthDot = prnCurrentPaper.paperHeightDot;
2113: prnRotatedHeightDot = prnCurrentPaper.paperWidthDot;
2114:
2115:
2116:
2117: prnM11 = 0;
2118: prnM12 = -1;
2119: prnM13 = prnRotatedWidthDot;
2120: prnM21 = 1;
2121: prnM22 = 0;
2122: prnM23 = 0;
2123: } else if (prnRotation == 2) {
2124: prnRotatedWidthDot = prnCurrentPaper.paperWidthDot;
2125: prnRotatedHeightDot = prnCurrentPaper.paperHeightDot;
2126:
2127:
2128:
2129: prnM11 = -1;
2130: prnM12 = 0;
2131: prnM13 = prnRotatedWidthDot;
2132: prnM21 = 0;
2133: prnM22 = -1;
2134: prnM23 = prnRotatedHeightDot;
2135: } else {
2136: prnRotatedWidthDot = prnCurrentPaper.paperHeightDot;
2137: prnRotatedHeightDot = prnCurrentPaper.paperWidthDot;
2138:
2139:
2140:
2141: prnM11 = 0;
2142: prnM12 = 1;
2143: prnM13 = 0;
2144: prnM21 = -1;
2145: prnM22 = 0;
2146: prnM23 = prnRotatedHeightDot;
2147: }
2148: prnIncrementX = prnM11 + prnRotatedWidthDot * prnM21;
2149: prnIncrementY = prnM12 + prnRotatedWidthDot * prnM22;
2150:
2151: prnDarkMode = prnNextDarkMode;
2152:
2153: prnImage = new BufferedImage (prnRotatedWidthDot,
2154: prnRotatedHeightDot,
2155: BufferedImage.TYPE_BYTE_INDEXED, prnDarkMode ? prnDarkImageColorModel : prnImageColorModel);
2156: prnBitmap = ((DataBufferByte) prnImage.getRaster ().getDataBuffer ()).getData ();
2157: if (prnCanvas != null) {
2158: prnCanvas.setImage (prnImage);
2159: }
2160:
2161: prnErasePaper ();
2162: }
2163:
2164:
2165:
2166:
2167: public static void prnErasePaper () {
2168: if (prnCurrentPaper == null) {
2169: prnFeedPaper ();
2170: } else {
2171:
2172: prnPageStart = 0;
2173: prnPageLength = ((prnAliveBottomY - prnAliveTopY + (360 - 1)) / 360) * 360;
2174:
2175: prnContentTopY = prnPageStart;
2176: prnContentBottomY = prnPageStart + prnPageLength - prnMarginBottomHeight;
2177:
2178: prnHeadX = prnMarginLeftX;
2179: prnHeadY = prnContentTopY;
2180: prnHeadLine = 0;
2181:
2182: Arrays.fill (prnBitmap, 0, prnRotatedWidthDot * prnRotatedHeightDot, (byte) 7);
2183:
2184: prnPrinted = false;
2185:
2186: if (prnCanvas != null) {
2187: prnCanvas.repaint ();
2188: }
2189: }
2190: }
2191:
2192:
2193:
2194: public static void prnEjectPaper () {
2195: if (prnCurrentPaper == null) {
2196: return;
2197: }
2198: if (prnPrinted) {
2199: prnPrinted = false;
2200: prnSavePaper ();
2201: }
2202: prnCurrentPaper = null;
2203: prnHeadX = -1;
2204: prnHeadY = -1;
2205: prnHeadLine = -1;
2206: if (prnCanvas != null) {
2207: prnCanvas.setImage (null);
2208: }
2209: }
2210:
2211:
2212:
2213:
2214:
2215:
2216:
2217:
2218:
2219: public static void prnSavePaper () {
2220:
2221: while (new File (prnSavePath + File.separator + prnSaveName).isFile ()) {
2222: int j = prnSaveName.lastIndexOf ('.');
2223: if (j < 0) {
2224: j = prnSaveName.length ();
2225: }
2226: int i = j;
2227: int n = 2;
2228: if (0 < j && Character.isDigit (prnSaveName.charAt (j - 1))) {
2229:
2230: i--;
2231: while (j - 8 < i &&
2232: 0 < i && Character.isDigit (prnSaveName.charAt (i - 1))) {
2233: i--;
2234: }
2235: n = Integer.parseInt (prnSaveName.substring (i, j));
2236: n = (n + 1) % 100000000;
2237: }
2238: prnSaveName = prnSaveName.substring (0, i) + n + prnSaveName.substring (j);
2239: }
2240:
2241: File file = new File (prnSavePath + File.separator + prnSaveName).getAbsoluteFile ();
2242: File parent = file.getParentFile ();
2243: prnSavePath = parent.getAbsolutePath ();
2244: prnSaveName = file.getName ();
2245: parent.mkdirs ();
2246:
2247: if (prnAutosaveOn) {
2248: if (!prnSave ()) {
2249: prnSetAutosaveOn (false);
2250: }
2251: }
2252: if (!prnAutosaveOn) {
2253: if (prnSaveDialog == null) {
2254: prnMakeSaveDialog ();
2255: }
2256: prnSaveFileChooser.setCurrentDirectory (parent);
2257: prnSaveFileChooser.rescanCurrentDirectory ();
2258: prnSaveFileChooser.setSelectedFile (file);
2259:
2260:
2261: XEiJ.pnlExitFullScreen (false);
2262: prnSaveDialog.setVisible (true);
2263: }
2264: }
2265:
2266: private static final byte[] PRN_DOUBLE_4BIT = {
2267: 0b00_00_00_00,
2268: 0b00_00_00_11,
2269: 0b00_00_11_00,
2270: 0b00_00_11_11,
2271: 0b00_11_00_00,
2272: 0b00_11_00_11,
2273: 0b00_11_11_00,
2274: 0b00_11_11_11,
2275: (byte) 0b11_00_00_00,
2276: (byte) 0b11_00_00_11,
2277: (byte) 0b11_00_11_00,
2278: (byte) 0b11_00_11_11,
2279: (byte) 0b11_11_00_00,
2280: (byte) 0b11_11_00_11,
2281: (byte) 0b11_11_11_00,
2282: (byte) 0b11_11_11_11,
2283: };
2284:
2285:
2286:
2287: public static void prnSetSingleColor (int color) {
2288: prnSingleColor = color;
2289: if (!prnColorMode) {
2290: prnCurrentColor = color;
2291: }
2292: }
2293:
2294:
2295:
2296: public static int prnGetCharacterWidth () {
2297: return (prnKanjiMode ?
2298: (prnHalfWidthLeftSpace + 24 + prnHalfWidthRightSpace) *
2299: (prnHorizontalDoubleSizeMode || prnKanjiHorizontalDoubleSizeMode ? 2 : 1) :
2300: (prnCharacterType == PRN_PICA ? 36 :
2301: prnCharacterType == PRN_ELITE ? 30 :
2302: prnCharacterType == PRN_SMALL ? 21 : 0) *
2303: (prnHorizontalDoubleSizeMode ? 2 : 1));
2304: }
2305:
2306:
2307:
2308:
2309: public static void prnPrintCharacter (int c) {
2310: c = (char) c;
2311: if (prnCurrentPaper == null) {
2312: prnFeedPaper ();
2313: }
2314:
2315: FontPage page = null;
2316: int y0 = 0;
2317: int col = 0;
2318: int row = 0;
2319: int w;
2320: int h;
2321: int o;
2322: int oh;
2323: byte[] b;
2324: gaiji:
2325: {
2326: if (c <= 0x00ff) {
2327: col = c & 15;
2328: row = c >> 4;
2329: if (prnKanjiMode) {
2330: page = prnHalfWidthFont == 0 ? fntPagePan24x48R : fntPagePan24x48S;
2331: } else {
2332: if (prnHiraganaMode) {
2333: row += 16;
2334: }
2335: if (prnCharacterType == PRN_PICA) {
2336: page = prnHalfWidthFont == 0 ? fntPagePic36x46R : fntPagePic36x46S;
2337: } else if (prnCharacterType == PRN_ELITE) {
2338: page = prnHalfWidthFont == 0 ? fntPageEli30x46R : fntPageEli30x46S;
2339: } else if (prnCharacterType == PRN_SMALL) {
2340: page = prnHalfWidthFont == 0 ? fntPageSma18x46R : fntPageSma18x46S;
2341: } else {
2342: page = prnHalfWidthFont == 0 ? fntPageScr28x32R : fntPageScr28x32S;
2343: if (prnScriptMode == 2) {
2344: y0 = 14;
2345: }
2346: }
2347: }
2348: } else {
2349: page = prnFullWidthFont == 0 ? fntPageZen48x48M : fntPageZen48x48G;
2350: row = c >> 8;
2351: col = c & 255;
2352: if (((0x81 <= row && row <= 0x9f) ||
2353: (0xe0 <= row && row <= 0xef)) &&
2354: ((0x40 <= col && col <= 0x7e) ||
2355: (0x80 <= col && col <= 0xfc))) {
2356:
2357:
2358:
2359:
2360:
2361: if (0xe0 <= row) {
2362: row -= 0xe0 - 0xa0;
2363: }
2364: row -= 0x81;
2365: if (0x80 <= col) {
2366: col -= 0x80 - 0x7f;
2367: }
2368: col -= 0x40;
2369: row *= 2;
2370: if (94 <= col) {
2371: row += 1;
2372: col -= 94;
2373: }
2374: row += 0x21;
2375: col += 0x21;
2376: }
2377: if ((row == 0x76 && (0x21 <= col && col <= 0x7e)) ||
2378: (row == 0x77 && (0x21 <= col && col <= 0x26))) {
2379: w = 48;
2380: h = 48;
2381: o = 6;
2382: oh = o * h;
2383: b = new byte[oh];
2384: System.arraycopy (prnGetGaijiData (), oh * ((col - 0x21) + 94 * (row - 0x76)), b, 0, oh);
2385: break gaiji;
2386: }
2387: if (0x21 <= col && col <= 0x7e) {
2388: col -= 0x21;
2389: if (0x21 <= row && row <= 0x28) {
2390: row -= 0x21;
2391: } else if (0x30 <= row && row <= 0x74) {
2392:
2393: row -= 0x21;
2394: } else {
2395: row = 0;
2396: col = 0;
2397: }
2398: } else {
2399: row = 0;
2400: col = 0;
2401: }
2402: }
2403: if (!page.fnpReady) {
2404: page.fnpCreateImage ((c <= 0x00ff ? prnHalfWidthFont : prnFullWidthFont) == 0 ? fntGetMinchoFamily () : fntGetGothicFamily ());
2405: }
2406: w = page.fnpCharacterWidth;
2407: h = page.fnpCharacterHeight;
2408: o = page.fnpCharacterHorizontalBytes;
2409: oh = o * h;
2410: b = new byte[o * y0 + oh];
2411: System.arraycopy (page.fnpBinaryArray, oh * (col + page.fnpImageCols * row), b, o * y0, oh);
2412: }
2413: h += y0;
2414: oh = o * h;
2415:
2416:
2417:
2418:
2419:
2420:
2421:
2422:
2423:
2424:
2425:
2426:
2427:
2428:
2429:
2430:
2431:
2432:
2433:
2434:
2435:
2436:
2437:
2438:
2439:
2440:
2441:
2442:
2443:
2444:
2445:
2446:
2447:
2448:
2449:
2450:
2451:
2452:
2453:
2454:
2455:
2456:
2457:
2458:
2459:
2460: if (prnVerticalWritingMode &&
2461: page != null && page.fnpImageCols == 94 &&
2462: !((row == 0x21 - 0x21 && ((0x26 - 0x21 <= col && col <= 0x28 - 0x21) ||
2463: (col == 0x5d - 0x21) ||
2464: (0x62 - 0x21 <= col && col <= 0x66 - 0x21))) ||
2465: (row == 0x22 - 0x21 && (0x2a - 0x21 <= col && col <= 0x2d - 0x21)) ||
2466: (row == 0x28 - 0x21 && (0x21 - 0x21 <= col && col <= 0x40 - 0x21)))) {
2467: boolean rotate;
2468: if (row == 0x21 - 0x21 && (0x22 - 0x21 <= col && col <= 0x23 - 0x21)) {
2469:
2470: byte[] bb = new byte[6 * 48];
2471:
2472:
2473: for (int yy = 0; yy < 48 / 3; yy++) {
2474: int y = yy + 48 * 2 / 3;
2475: for (int xx = 48 * 2 / 3; xx < 48; xx++) {
2476: int x = xx - 48 * 2 / 3;
2477: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2478: }
2479: }
2480: b = bb;
2481: rotate = true;
2482: } else if (row == 0x21 - 0x21 && (col == 0x3c - 0x21 ||
2483: col == 0x41 - 0x21)) {
2484:
2485: byte[] bb = new byte[6 * 48];
2486:
2487:
2488: for (int yy = 0; yy < 48; yy++) {
2489: int y = 48 - 1 - yy;
2490: for (int xx = 0; xx < 48; xx++) {
2491: int x = xx;
2492: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2493: }
2494: }
2495: b = bb;
2496: rotate = false;
2497: } else if ((row == 0x24 - 0x21 && (col == 0x21 - 0x21 ||
2498: col == 0x23 - 0x21 ||
2499: col == 0x25 - 0x21 ||
2500: col == 0x27 - 0x21 ||
2501: col == 0x29 - 0x21 ||
2502: col == 0x43 - 0x21 ||
2503: col == 0x63 - 0x21 ||
2504: col == 0x65 - 0x21 ||
2505: col == 0x67 - 0x21 ||
2506: col == 0x6e - 0x21)) ||
2507: (row == 0x25 - 0x21 && (col == 0x21 - 0x21 ||
2508: col == 0x23 - 0x21 ||
2509: col == 0x25 - 0x21 ||
2510: col == 0x27 - 0x21 ||
2511: col == 0x29 - 0x21 ||
2512: col == 0x43 - 0x21 ||
2513: col == 0x63 - 0x21 ||
2514: col == 0x65 - 0x21 ||
2515: col == 0x67 - 0x21 ||
2516: col == 0x6e - 0x21 ||
2517: col == 0x75 - 0x21 ||
2518: col == 0x76 - 0x21))) {
2519:
2520: byte[] bb = new byte[6 * 48];
2521:
2522:
2523: for (int yy = 0; yy < 48 * 7 / 8; yy++) {
2524: int y = yy + 48 / 8;
2525: for (int xx = 48 / 8; xx < 48; xx++) {
2526: int x = xx - 48 / 8;
2527: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2528: }
2529: }
2530: b = bb;
2531: rotate = true;
2532: } else if (row == 0x21 - 0x21 && ((0x31 - 0x21 <= col && col <= 0x32 - 0x21) ||
2533: (0x3d - 0x21 <= col && col <= 0x3e - 0x21) ||
2534: (0x42 - 0x21 <= col && col <= 0x45 - 0x21) ||
2535: (0x4a - 0x21 <= col && col <= 0x5b - 0x21) ||
2536: col == 0x61 - 0x21)) {
2537: rotate = false;
2538: } else {
2539: rotate = true;
2540: }
2541: if (rotate) {
2542:
2543:
2544:
2545: byte[] bb = new byte[6 * 48];
2546:
2547:
2548: for (int yy = 0; yy < 48; yy++) {
2549: int x = 48 - 1 - yy;
2550: for (int xx = 0; xx < 48; xx++) {
2551: int y = xx;
2552: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2553: }
2554: }
2555: b = bb;
2556: }
2557: }
2558: if (false) {
2559:
2560:
2561:
2562: if (h < 48) {
2563: int hh = 48;
2564: int ohh = o * hh;
2565: byte[] bb = new byte[ohh];
2566: System.arraycopy (b, 0, bb, 0, oh);
2567:
2568: h = hh;
2569: oh = ohh;
2570: b = bb;
2571: }
2572: }
2573:
2574: {
2575: int lw = 0;
2576: int rw = 0;
2577: if (prnKanjiMode) {
2578: if (w == 48) {
2579: lw = prnFullWidthLeftSpace;
2580: rw = prnFullWidthRightSpace;
2581: } else {
2582: lw = prnHalfWidthLeftSpace;
2583: rw = prnHalfWidthRightSpace;
2584: }
2585: } else if (prnCharacterType == PRN_SMALL) {
2586: rw = 3;
2587: }
2588: if (lw != 0 || rw != 0) {
2589: int ww = lw + w + rw;
2590: int oo = (ww + 7) >> 3;
2591: int ooh = oo * h;
2592: byte[] bb = new byte[ooh];
2593: Arrays.fill (bb, (byte) 0);
2594:
2595: int lq = lw >> 3;
2596: int lr = lw & 7;
2597: if (lr == 0) {
2598: for (int a = 0, aa = lq; a < oh; a += o, aa += oo) {
2599: for (int i = o - 1; 0 <= i; i--) {
2600: bb[aa + i] = b[a + i];
2601: }
2602: }
2603: } else {
2604: for (int a = 0, aa = lq; a < oh; a += o, aa += oo) {
2605: bb[aa + o] = (byte) (b[a + o - 1] << (8 - lr));
2606: for (int i = o - 1; 0 < i; i--) {
2607: bb[aa + i] = (byte) ((b[a + i - 1] << (8 - lr)) | (b[a + i] & 255) >> lr);
2608: }
2609: bb[aa] = (byte) ((b[a] & 255) >> lr);
2610: }
2611: }
2612: w = ww;
2613: o = oo;
2614: oh = ooh;
2615: b = bb;
2616: }
2617: }
2618:
2619: if (prnStrongMode) {
2620:
2621:
2622: for (int a = 0; a < oh; a += o) {
2623: for (int i = o - 1; 0 < i; i--) {
2624: b[a + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2625: }
2626: b[a] |= (byte) ((b[a] & 255) >> 1);
2627: }
2628: }
2629:
2630: if (prnCharacterStyle != 0) {
2631:
2632:
2633:
2634:
2635:
2636:
2637:
2638:
2639: byte[] bb = new byte[oh];
2640: Arrays.fill (bb, (byte) 0);
2641: if (prnVerticalWritingMode) {
2642:
2643: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2644: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2645: for (int i = 1; i < o; i++) {
2646: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2647: }
2648: }
2649: } else {
2650:
2651: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2652: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2653: for (int i = 1; i < o; i++) {
2654: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2655: }
2656: }
2657: }
2658: if (prnCharacterStyle == PRN_SHADOW_STYLE ||
2659: prnCharacterStyle == PRN_OPEN_SHADOW_STYLE) {
2660: if (prnVerticalWritingMode) {
2661:
2662: for (int a = o * 2, aa = 0; a < oh; a += o, aa += o) {
2663: bb[aa] |= (byte) ((b[a] & 255) >> 2);
2664: for (int i = 1; i < o; i++) {
2665: bb[aa + i] |= (byte) (b[a + i - 1] << 6 | (b[a + i] & 255) >> 2);
2666: }
2667: }
2668: } else {
2669:
2670: for (int a = 0, aa = o * 2; aa < oh; a += o, aa += o) {
2671: bb[aa] |= (byte) ((b[a] & 255) >> 2);
2672: for (int i = 1; i < o; i++) {
2673: bb[aa + i] |= (byte) (b[a + i - 1] << 6 | (b[a + i] & 255) >> 2);
2674: }
2675: }
2676: }
2677: }
2678: if (prnCharacterStyle == PRN_OPEN_STYLE ||
2679: prnCharacterStyle == PRN_OPEN_SHADOW_STYLE) {
2680:
2681: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2682: for (int i = 0; i < o - 1; i++) {
2683: bb[aa + i] |= (byte) (b[a + i] << 1 | (b[a + i + 1] & 255) >> 7);
2684: }
2685: bb[aa + o - 1] |= (byte) (b[a + o - 1] << 1);
2686: }
2687:
2688: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2689: for (int i = 0; i < o; i++) {
2690: bb[aa + i] |= b[a + i];
2691: }
2692: }
2693: if (prnVerticalWritingMode) {
2694:
2695: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2696: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2697: for (int i = 1; i < o; i++) {
2698: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2699: }
2700: }
2701: } else {
2702:
2703: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2704: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2705: for (int i = 1; i < o; i++) {
2706: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2707: }
2708: }
2709: }
2710:
2711: for (int a = 0; a < oh; a += o) {
2712: for (int i = 0; i < o - 1; i++) {
2713: bb[a + i] |= (byte) (b[a + i] << 1 | (b[a + i + 1] & 255) >> 7);
2714: }
2715: bb[a + o - 1] |= (byte) (b[a + o - 1] << 1);
2716: }
2717:
2718: for (int a = 0; a < oh; a += o) {
2719: bb[a] |= (byte) ((b[a] & 255) >> 1);
2720: for (int i = 1; i < o; i++) {
2721: bb[a + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2722: }
2723: }
2724:
2725: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2726: for (int i = 0; i < o - 1; i++) {
2727: bb[aa + i] |= (byte) (b[a + i] << 1 | (b[a + i + 1] & 255) >> 7);
2728: }
2729: bb[aa + o - 1] |= (byte) (b[a + o - 1] << 1);
2730: }
2731:
2732: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2733: for (int i = 0; i < o; i++) {
2734: bb[aa + i] |= b[a + i];
2735: }
2736: }
2737: }
2738:
2739: for (int i = 0; i < oh; i++) {
2740: bb[i] &= (byte) ~b[i];
2741: }
2742: b = bb;
2743: }
2744:
2745:
2746: if (prnUnderlineMode) {
2747: if (prnVerticalWritingMode) {
2748: int a = 0;
2749: for (int i = 0; i < o - 1; i++) {
2750: b[a + i] = -1;
2751: }
2752: b[a + o - 1] |= (byte) (-256 >> (((w - 1) & 7) + 1));
2753: } else {
2754: int a = o * (h - 1);
2755: for (int i = 0; i < o - 1; i++) {
2756: b[a + i] = -1;
2757: }
2758: b[a + o - 1] |= (byte) (-256 >> (((w - 1) & 7) + 1));
2759: }
2760: }
2761:
2762: if (prnHorizontalDoubleSizeMode ||
2763: (prnKanjiMode && prnKanjiHorizontalDoubleSizeMode)) {
2764: int ww = w * 2;
2765: int oo = (ww + 7) >> 3;
2766: int ooh = oo * h;
2767: byte[] bb = new byte[ooh];
2768: for (int a = 0, aa = 0; a < oh; a += o, aa += oo) {
2769: for (int i = 0, ii = 0; i < o; i++, ii += 2) {
2770: int d = b[a + i] & 255;
2771: bb[aa + ii] = PRN_DOUBLE_4BIT[d >> 4];
2772: if (ii + 1 < oo) {
2773: bb[aa + ii + 1] = PRN_DOUBLE_4BIT[d & 15];
2774: }
2775: }
2776: }
2777: w = ww;
2778: o = oo;
2779: oh = ooh;
2780: b = bb;
2781: }
2782:
2783: if (prnVerticalDoubleSizeMode) {
2784: int hh = h * 2;
2785: int ohh = o * hh;
2786: byte[] bb = new byte[ohh];
2787: for (int a = 0, aa = 0; a < oh; a += o, aa += o * 2) {
2788: for (int i = 0; i < o; i++) {
2789: bb[aa + o + i] = bb[aa + i] = b[a + i];
2790: }
2791: }
2792: h = hh;
2793: oh = ohh;
2794: b = bb;
2795: }
2796:
2797: if (prnMarginLeftX < prnHeadX &&
2798: prnMarginRightX < prnHeadX + w) {
2799:
2800: prnHeadX = prnMarginLeftX;
2801: prnHeadY += prnLineHeight;
2802: prnHeadLine++;
2803: }
2804:
2805: if (prnContentTopY < prnHeadY &&
2806: prnContentBottomY < prnHeadY + h) {
2807:
2808: prnPrintFormFeed ();
2809: }
2810:
2811: int bi = prnCheckRect (w, h);
2812: if (0 <= bi) {
2813: int ix = prnIncrementX;
2814: int iy = prnIncrementY;
2815: for (int y = 0; y < h; y++) {
2816: int i = bi;
2817: for (int x = 0; x < w; x++) {
2818: if ((b[(x >> 3) + o * y] >> (~x & 7) & 1) != 0) {
2819: prnBitmap[i] &= (byte) prnCurrentColor;
2820: }
2821: i += ix;
2822: }
2823: bi += iy;
2824: }
2825: } else {
2826: for (int y = 0; y < h; y++) {
2827: for (int x = 0; x < w; x++) {
2828: if ((b[(x >> 3) + o * y] >> (~x & 7) & 1) != 0) {
2829: prnPaintDot (x, y);
2830: }
2831: }
2832: }
2833: }
2834: prnHeadX += w;
2835:
2836: prnPrinted = true;
2837:
2838: if (prnCanvas != null) {
2839: prnCanvas.repaint ();
2840: }
2841: }
2842:
2843:
2844:
2845:
2846:
2847:
2848:
2849: public static void prnPrintBackSpace () {
2850: if (prnCurrentPaper == null) {
2851: prnFeedPaper ();
2852: }
2853: prnHeadX = Math.max (prnMarginLeftX, prnHeadX - prnGetCharacterWidth ());
2854: }
2855:
2856:
2857:
2858:
2859:
2860: public static void prnPrintHorizontalTab () {
2861: if (prnCurrentPaper == null) {
2862: prnFeedPaper ();
2863: }
2864: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
2865: int x = prnHorizontalTabAnchor[k];
2866: if (x == 0) {
2867: break;
2868: }
2869: if (prnHeadX < x) {
2870: prnHeadX = Math.min (x, prnMarginRightX - 1);
2871: break;
2872: }
2873: }
2874: }
2875:
2876:
2877:
2878:
2879:
2880:
2881: public static void prnSetStartColumn (int n) {
2882: if (prnCurrentPaper == null) {
2883: prnFeedPaper ();
2884: }
2885: if (0 <= n && n <= 999) {
2886: int startX = prnGetCharacterWidth () * n;
2887: if (prnMarginLeftX + startX < prnMarginRightX) {
2888: prnHeadX = prnMarginLeftX + startX;
2889: }
2890: }
2891: }
2892:
2893:
2894:
2895:
2896:
2897:
2898: public static void prnPrintLineFeed (int n) {
2899: if (prnCurrentPaper == null) {
2900: prnFeedPaper ();
2901: }
2902: if (n < 0) {
2903: n = 0;
2904: }
2905: if (prnVerticalDoubleSizeMode) {
2906: n *= 2;
2907: }
2908:
2909: prnHeadY += prnLineHeight * n;
2910: prnHeadLine += n;
2911:
2912: if (prnContentBottomY <= prnHeadY) {
2913:
2914: prnPrintFormFeed ();
2915: }
2916:
2917: if (prnColorMode) {
2918: prnColorMode = false;
2919: prnCurrentColor = prnSingleColor;
2920: }
2921: }
2922:
2923:
2924:
2925:
2926:
2927:
2928: public static void prnPrintVerticalTab (int n) {
2929: if (prnCurrentPaper == null) {
2930: prnFeedPaper ();
2931: }
2932: for (int k = prnHeadLine; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
2933: if (prnVerticalTabAnchor[k] == n) {
2934: int d = k - prnHeadLine;
2935:
2936: prnHeadX = prnMarginLeftX;
2937: prnHeadY += prnLineHeight * d;
2938: prnHeadLine += d;
2939:
2940: if (prnContentBottomY <= prnHeadY) {
2941:
2942: prnPrintFormFeed ();
2943: }
2944: return;
2945: }
2946: }
2947: }
2948:
2949:
2950:
2951:
2952: public static void prnPrintFormFeed () {
2953:
2954: prnPageStart += prnPageLength;
2955:
2956: prnContentTopY = prnPageStart;
2957: prnContentBottomY = Math.min (prnPageStart + prnPageLength - prnMarginBottomHeight,
2958: prnAliveBottomY - prnAliveTopY);
2959:
2960: prnHeadX = prnMarginLeftX;
2961: prnHeadY = prnContentTopY;
2962: prnHeadLine = 0;
2963:
2964: if (prnAliveBottomY <= prnAliveTopY + prnHeadY) {
2965: prnEjectPaper ();
2966: prnFeedPaper ();
2967: }
2968: }
2969:
2970:
2971:
2972:
2973: public static void prnPrintCarriageReturn () {
2974: if (prnCurrentPaper == null) {
2975: prnFeedPaper ();
2976: }
2977:
2978: prnHeadX = prnMarginLeftX;
2979:
2980: if (prnColorMode) {
2981: prnCurrentColor = prnCurrentColor == 6 ? 5 : prnCurrentColor == 5 ? 3 : 6;
2982: }
2983: }
2984:
2985:
2986:
2987:
2988:
2989: public static void prnSetHorizontalDoubleSizeMode (boolean b) {
2990: prnHorizontalDoubleSizeMode = b;
2991: }
2992:
2993:
2994:
2995:
2996: public static void prnSelect (boolean b) {
2997:
2998: }
2999:
3000:
3001:
3002:
3003:
3004:
3005:
3006:
3007:
3008: public static void prnSetVerticalTabAnchor (byte[] a, int o, int n) {
3009: if (prnCurrentPaper == null) {
3010: prnFeedPaper ();
3011: }
3012: prnSetPageStartPosition ();
3013: int pp = '0';
3014: int k = 0;
3015: for (; k < PRN_VERTICAL_ANCHOR_LIMIT && k < n; k++) {
3016: int p = a[o + k];
3017: if (p == '0') {
3018: prnVerticalTabAnchor[k] = 0;
3019: } else if ('1' <= p && p <= '<') {
3020: if (p <= pp) {
3021: break;
3022: }
3023: prnVerticalTabAnchor[k] = p - '0';
3024: pp = p;
3025: } else {
3026: break;
3027: }
3028: }
3029: for (; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
3030: prnVerticalTabAnchor[k] = 0;
3031: }
3032: }
3033:
3034:
3035:
3036: public static void prnCancel () {
3037:
3038: }
3039:
3040:
3041:
3042:
3043: public static void prnSetVerticalDoubleSizeMode (boolean b) {
3044: prnVerticalDoubleSizeMode = b;
3045: }
3046:
3047:
3048:
3049:
3050: public static void prnSetHorizontalStartPosition (int n) {
3051: if (prnCurrentPaper == null) {
3052: prnFeedPaper ();
3053: }
3054: if (0 <= n && n <= 9999) {
3055: int startX = 2 * n;
3056: if (prnMarginLeftX + startX < prnMarginRightX) {
3057: prnHeadX = prnMarginLeftX + startX;
3058: }
3059: }
3060: }
3061:
3062:
3063:
3064: public static void prnSetColorMode () {
3065: prnColorMode = true;
3066: prnCurrentColor = 6;
3067: }
3068:
3069:
3070:
3071:
3072: public static void prnSetStrongMode (boolean b) {
3073: prnStrongMode = b;
3074: }
3075:
3076:
3077:
3078:
3079: public static void prnSetHiraganaMode (boolean b) {
3080: prnHiraganaMode = b;
3081: }
3082:
3083:
3084:
3085:
3086:
3087:
3088: public static void prnSetLineHeight (int n) {
3089: if (0 <= n && n <= 127) {
3090: if (n == 0) {
3091: prnLineHeight = prnDefaultLineHeight;
3092: } else {
3093: prnLineHeight = 3 * n;
3094: }
3095: }
3096: }
3097:
3098:
3099:
3100:
3101:
3102:
3103:
3104:
3105:
3106:
3107:
3108:
3109:
3110:
3111: public static void prn8DotBitImage (byte[] a, int o, int n) {
3112: if (prnCurrentPaper == null) {
3113: prnFeedPaper ();
3114: }
3115:
3116: }
3117:
3118:
3119:
3120:
3121:
3122:
3123:
3124:
3125:
3126: public static void prnSetHorizontalTabAnchor (byte[] a, int o, int n) {
3127: if (prnCurrentPaper == null) {
3128: prnFeedPaper ();
3129: }
3130: int characterWidth = prnGetCharacterWidth ();
3131: n += o;
3132: int k = 0;
3133: while (k < PRN_HORIZONTAL_ANCHOR_LIMIT &&
3134: o < n && '0' <= a[o] && a[o] <= '9') {
3135: int p = a[o] - '0';
3136: o++;
3137: while (o < n && '0' <= a[o] && a[o] <= '9') {
3138: p = p * 10 + (a[o] - '0');
3139: o++;
3140: }
3141: int x = prnMarginLeftX + characterWidth * p;
3142: if ((k == 0 ? prnMarginLeftX :
3143: prnHorizontalTabAnchor[k - 1]) < x) {
3144: prnHorizontalTabAnchor[k] = x;
3145: k++;
3146: }
3147: if (o < n && a[o] == ',') {
3148: o++;
3149: } else {
3150: break;
3151: }
3152: }
3153: for (; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3154: prnHorizontalTabAnchor[k] = 0;
3155: }
3156: }
3157:
3158:
3159:
3160:
3161:
3162:
3163: public static void prnClearHorizontalTabAnchor (byte[] a, int o, int n) {
3164: if (prnCurrentPaper == null) {
3165: prnFeedPaper ();
3166: }
3167: int characterWidth = prnGetCharacterWidth ();
3168: n += o;
3169: while (o < n && '0' <= a[o] && a[o] <= '9') {
3170: int p = a[o] - '0';
3171: o++;
3172: while (o < n && '0' <= a[o] && a[o] <= '9') {
3173: p = p * 10 + (a[o] - '0');
3174: o++;
3175: }
3176: int x = prnMarginLeftX + characterWidth * p;
3177: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3178: int t = prnHorizontalTabAnchor[k];
3179: if (t == 0 ||
3180: x < t) {
3181: break;
3182: }
3183: if (t == x) {
3184: int j = k;
3185: for (; j < PRN_HORIZONTAL_ANCHOR_LIMIT - 1; j++) {
3186: prnHorizontalTabAnchor[j] = prnHorizontalTabAnchor[j + 1];
3187: }
3188: prnHorizontalTabAnchor[j] = 0;
3189: break;
3190: }
3191: }
3192: if (o < n && a[o] == ',') {
3193: o++;
3194: } else {
3195: break;
3196: }
3197: }
3198: }
3199:
3200:
3201:
3202:
3203:
3204:
3205:
3206:
3207:
3208:
3209:
3210:
3211:
3212:
3213:
3214:
3215:
3216:
3217:
3218:
3219:
3220:
3221:
3222:
3223:
3224:
3225:
3226:
3227: public static void prn16DotExtendedCharacterDefinition (byte[] a, int o, int n) {
3228: byte[] gaijiData = prnGetGaijiData ();
3229: int n1 = a[o] & 255;
3230: int n2 = a[o + 1] & 255;
3231: if (!((n1 == 0x76 && (0x21 <= n2 && n2 <= 0x7e)) ||
3232: (n1 == 0x77 && (0x21 <= n2 && n2 <= 0x26)))) {
3233: return;
3234: }
3235: int i = 6 * 48 * ((n2 - 0x21) + 94 * (n1 - 0x76));
3236: int j = o + 2;
3237: for (int y = 0; y < 16; y++) {
3238: int t = 0;
3239: for (int x = 0; x < 8; x++) {
3240: t = t << 3 | (a[j + 2 * x + (y >> 3)] >> (~y & 7) & 1) * 7;
3241: }
3242: gaijiData[i ] = gaijiData[i + 6] = gaijiData[i + 12] = (byte) (t >> 16);
3243: gaijiData[i + 1] = gaijiData[i + 7] = gaijiData[i + 13] = (byte) (t >> 8);
3244: gaijiData[i + 2] = gaijiData[i + 8] = gaijiData[i + 14] = (byte) t;
3245: t = 0;
3246: for (int x = 8; x < 16; x++) {
3247: t = t << 3 | (a[j + 2 * x + (y >> 3)] >> (~y & 7) & 1) * 7;
3248: }
3249: gaijiData[i + 3] = gaijiData[i + 9] = gaijiData[i + 15] = (byte) (t >> 16);
3250: gaijiData[i + 4] = gaijiData[i + 10] = gaijiData[i + 16] = (byte) (t >> 8);
3251: gaijiData[i + 5] = gaijiData[i + 11] = gaijiData[i + 17] = (byte) t;
3252: i += 18;
3253: }
3254: }
3255:
3256:
3257:
3258:
3259:
3260:
3261:
3262:
3263:
3264:
3265:
3266:
3267:
3268:
3269:
3270:
3271:
3272:
3273:
3274:
3275:
3276:
3277:
3278:
3279:
3280:
3281:
3282:
3283:
3284:
3285:
3286:
3287:
3288:
3289:
3290:
3291:
3292:
3293: public static void prn24DotExtendedCharacterDefinition (byte[] a, int o, int n) {
3294: byte[] gaijiData = prnGetGaijiData ();
3295: int n1 = a[o] & 255;
3296: int n2 = a[o + 1] & 255;
3297: if (!((n1 == 0x76 && (0x21 <= n2 && n2 <= 0x7e)) ||
3298: (n1 == 0x77 && (0x21 <= n2 && n2 <= 0x26)))) {
3299: return;
3300: }
3301: int i = 6 * 48 * ((n2 - 0x21) + 94 * (n1 - 0x76));
3302: int j = o + 2;
3303: for (int y = 0; y < 24; y++) {
3304: int t = 0;
3305: for (int x = 0; x < 16; x++) {
3306: t = t << 2 | (a[j + 3 * x + (y >> 3)] >> (~y & 7) & 1) * 3;
3307: }
3308: gaijiData[i ] = gaijiData[i + 6] = (byte) (t >> 24);
3309: gaijiData[i + 1] = gaijiData[i + 7] = (byte) (t >> 16);
3310: gaijiData[i + 2] = gaijiData[i + 8] = (byte) (t >> 8);
3311: gaijiData[i + 3] = gaijiData[i + 9] = (byte) t;
3312: t = 0;
3313: for (int x = 16; x < 24; x++) {
3314: t = t << 2 | (a[j + 3 * x + (y >> 3)] >> (~y & 7) & 1) * 3;
3315: }
3316: gaijiData[i + 4] = gaijiData[i + 10] = (byte) (t >> 8);
3317: gaijiData[i + 5] = gaijiData[i + 11] = (byte) t;
3318: i += 12;
3319: }
3320: }
3321:
3322:
3323:
3324:
3325:
3326:
3327:
3328:
3329:
3330: public static void prnSetRightMargin (int n) {
3331: if (prnCurrentPaper == null) {
3332: prnFeedPaper ();
3333: }
3334: if (0 <= n && n <= 999) {
3335: int rightX = prnGetCharacterWidth () * n;
3336: if (prnMarginLeftX < rightX) {
3337: prnMarginRightX = rightX;
3338:
3339: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3340: prnHorizontalTabAnchor[k] = 0;
3341: }
3342: }
3343: }
3344: }
3345:
3346:
3347:
3348: public static void prnClearAllHorizontalTabAnchor () {
3349: if (prnCurrentPaper == null) {
3350: prnFeedPaper ();
3351: }
3352:
3353: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3354: prnHorizontalTabAnchor[k] = 0;
3355: }
3356: }
3357:
3358:
3359:
3360:
3361: public static void prnSetPageStartPosition () {
3362: if (prnCurrentPaper == null) {
3363: prnFeedPaper ();
3364: }
3365:
3366: prnPageStart = prnHeadY;
3367:
3368: prnContentTopY = prnPageStart;
3369: prnContentBottomY = Math.min (prnPageStart + prnPageLength - prnMarginBottomHeight,
3370: prnAliveBottomY - prnAliveTopY);
3371:
3372: prnHeadX = prnMarginLeftX;
3373: prnHeadY = prnContentTopY;
3374: prnHeadLine = 0;
3375: }
3376:
3377:
3378:
3379: public static void prnSetOneSixth () {
3380: prnLineHeight = 60;
3381: prnDefaultLineHeight = 60;
3382: }
3383:
3384:
3385:
3386: public static void prnSetOneEighth () {
3387: prnLineHeight = 45;
3388: prnDefaultLineHeight = 45;
3389: }
3390:
3391:
3392:
3393:
3394:
3395:
3396:
3397: public static void prnSetBottomMargin (int n) {
3398: if (prnCurrentPaper == null) {
3399: prnFeedPaper ();
3400: }
3401: if (0 <= n && n <= 99) {
3402: int height = prnLineHeight * n;
3403: if (height < prnPageLength) {
3404: prnMarginBottomHeight = height;
3405:
3406: prnContentBottomY = Math.min (prnPageStart + prnPageLength - height,
3407: prnAliveBottomY - prnAliveTopY);
3408:
3409: if (prnContentBottomY <= prnHeadY) {
3410:
3411: prnPrintFormFeed ();
3412: }
3413:
3414: for (int k = 0; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
3415: prnVerticalTabAnchor[k] = 0;
3416: }
3417: }
3418: }
3419: }
3420:
3421:
3422:
3423:
3424:
3425: public static void prnSetEliteCharacterMode () {
3426: prnCharacterType = PRN_ELITE;
3427: }
3428:
3429:
3430:
3431:
3432:
3433:
3434:
3435: public static void prnSetPageHeight (int n) {
3436: if (prnCurrentPaper == null) {
3437: prnFeedPaper ();
3438: }
3439: prnSetPageStartPosition ();
3440: if (1 <= n && n <= 99) {
3441:
3442: prnPageLength = 180 * n;
3443:
3444: prnMarginBottomHeight = 0;
3445:
3446: prnSetPageStartPosition ();
3447: }
3448: }
3449:
3450:
3451:
3452:
3453:
3454:
3455:
3456:
3457: public static void prn16DotBitImage (byte[] a, int o, int n) {
3458: if (prnCurrentPaper == null) {
3459: prnFeedPaper ();
3460: }
3461:
3462: if (prnLineHeight == 45) {
3463: prnLineHeight = 48;
3464: }
3465: if (!prnHorizontalDoubleSizeMode) {
3466: if (!prnVerticalDoubleSizeMode) {
3467:
3468: int aw = n;
3469: int ah = 16;
3470: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
3471: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
3472: int bi = prnCheckRect (3 * aw, 3 * ah);
3473: if (0 <= bi) {
3474: int ix = prnIncrementX;
3475: int iy = prnIncrementY;
3476: for (int ay = 0; ay < ah; ay++) {
3477: int i = bi;
3478: for (int ax = 0; ax < aw; ax++) {
3479: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3480: prnBitmap[i ] &= (byte) prnCurrentColor;
3481: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3482: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3483: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3484: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3485: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3486: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3487: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3488: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3489: }
3490: i += 3 * ix;
3491: }
3492: bi += 3 * iy;
3493: }
3494: } else {
3495: for (int ay = 0; ay < ah; ay++) {
3496: for (int ax = 0; ax < aw; ax++) {
3497: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3498: prnPaintDot (3 * ax , 3 * ay );
3499: prnPaintDot (3 * ax + 1, 3 * ay );
3500: prnPaintDot (3 * ax + 2, 3 * ay );
3501: prnPaintDot (3 * ax , 3 * ay + 1);
3502: prnPaintDot (3 * ax + 1, 3 * ay + 1);
3503: prnPaintDot (3 * ax + 2, 3 * ay + 1);
3504: prnPaintDot (3 * ax , 3 * ay + 2);
3505: prnPaintDot (3 * ax + 1, 3 * ay + 2);
3506: prnPaintDot (3 * ax + 2, 3 * ay + 2);
3507: }
3508: }
3509: }
3510: }
3511: prnHeadX += 3 * aw;
3512: } else {
3513:
3514: int aw = n;
3515: int ah = 16;
3516: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
3517: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
3518: int bi = prnCheckRect (3 * aw, 6 * ah);
3519: if (0 <= bi) {
3520: int ix = prnIncrementX;
3521: int iy = prnIncrementY;
3522: for (int ay = 0; ay < ah; ay++) {
3523: int i = bi;
3524: for (int ax = 0; ax < aw; ax++) {
3525: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3526: prnBitmap[i ] &= (byte) prnCurrentColor;
3527: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3528: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3529: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3530: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3531: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3532: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3533: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3534: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3535: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3536: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3537: prnBitmap[i + 2 * ix * 3 * iy] &= (byte) prnCurrentColor;
3538: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
3539: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
3540: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
3541: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
3542: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
3543: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
3544: }
3545: i += 3 * ix;
3546: }
3547: bi += 6 * iy;
3548: }
3549: } else {
3550: for (int ay = 0; ay < ah; ay++) {
3551: for (int ax = 0; ax < aw; ax++) {
3552: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3553: prnPaintDot (3 * ax , 6 * ay );
3554: prnPaintDot (3 * ax + 1, 6 * ay );
3555: prnPaintDot (3 * ax + 2, 6 * ay );
3556: prnPaintDot (3 * ax , 6 * ay + 1);
3557: prnPaintDot (3 * ax + 1, 6 * ay + 1);
3558: prnPaintDot (3 * ax + 2, 6 * ay + 1);
3559: prnPaintDot (3 * ax , 6 * ay + 2);
3560: prnPaintDot (3 * ax + 1, 6 * ay + 2);
3561: prnPaintDot (3 * ax + 2, 6 * ay + 2);
3562: prnPaintDot (3 * ax , 6 * ay + 3);
3563: prnPaintDot (3 * ax + 1, 6 * ay + 3);
3564: prnPaintDot (3 * ax + 2, 6 * ay + 3);
3565: prnPaintDot (3 * ax , 6 * ay + 4);
3566: prnPaintDot (3 * ax + 1, 6 * ay + 4);
3567: prnPaintDot (3 * ax + 2, 6 * ay + 4);
3568: prnPaintDot (3 * ax , 6 * ay + 5);
3569: prnPaintDot (3 * ax + 1, 6 * ay + 5);
3570: prnPaintDot (3 * ax + 2, 6 * ay + 5);
3571: }
3572: }
3573: }
3574: }
3575: prnHeadX += 3 * aw;
3576: }
3577: } else {
3578: if (!prnVerticalDoubleSizeMode) {
3579:
3580: int aw = n;
3581: int ah = 16;
3582: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
3583: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
3584: int bi = prnCheckRect (6 * aw, 3 * ah);
3585: if (0 <= bi) {
3586: int ix = prnIncrementX;
3587: int iy = prnIncrementY;
3588: for (int ay = 0; ay < ah; ay++) {
3589: int i = bi;
3590: for (int ax = 0; ax < aw; ax++) {
3591: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3592: prnBitmap[i ] &= (byte) prnCurrentColor;
3593: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3594: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3595: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3596: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
3597: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
3598: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3599: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3600: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3601: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3602: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
3603: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
3604: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3605: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3606: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3607: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
3608: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
3609: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
3610: }
3611: i += 6 * ix;
3612: }
3613: bi += 3 * iy;
3614: }
3615: } else {
3616: for (int ay = 0; ay < ah; ay++) {
3617: for (int ax = 0; ax < aw; ax++) {
3618: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3619: prnPaintDot (6 * ax , 3 * ay );
3620: prnPaintDot (6 * ax + 1, 3 * ay );
3621: prnPaintDot (6 * ax + 2, 3 * ay );
3622: prnPaintDot (6 * ax + 3, 3 * ay );
3623: prnPaintDot (6 * ax + 4, 3 * ay );
3624: prnPaintDot (6 * ax + 5, 3 * ay );
3625: prnPaintDot (6 * ax , 3 * ay + 1);
3626: prnPaintDot (6 * ax + 1, 3 * ay + 1);
3627: prnPaintDot (6 * ax + 2, 3 * ay + 1);
3628: prnPaintDot (6 * ax + 3, 3 * ay + 1);
3629: prnPaintDot (6 * ax + 4, 3 * ay + 1);
3630: prnPaintDot (6 * ax + 5, 3 * ay + 1);
3631: prnPaintDot (6 * ax , 3 * ay + 2);
3632: prnPaintDot (6 * ax + 1, 3 * ay + 2);
3633: prnPaintDot (6 * ax + 2, 3 * ay + 2);
3634: prnPaintDot (6 * ax + 3, 3 * ay + 2);
3635: prnPaintDot (6 * ax + 4, 3 * ay + 2);
3636: prnPaintDot (6 * ax + 5, 3 * ay + 2);
3637: }
3638: }
3639: }
3640: }
3641: prnHeadX += 6 * aw;
3642: } else {
3643:
3644: int aw = n;
3645: int ah = 16;
3646: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
3647: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
3648: int bi = prnCheckRect (6 * aw, 6 * ah);
3649: if (0 <= bi) {
3650: int ix = prnIncrementX;
3651: int iy = prnIncrementY;
3652: for (int ay = 0; ay < ah; ay++) {
3653: int i = bi;
3654: for (int ax = 0; ax < aw; ax++) {
3655: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3656: prnBitmap[i ] &= (byte) prnCurrentColor;
3657: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3658: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3659: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3660: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
3661: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
3662: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3663: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3664: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3665: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3666: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
3667: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
3668: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3669: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3670: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3671: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
3672: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
3673: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
3674: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3675: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3676: prnBitmap[i + 2 * ix * 3 * iy] &= (byte) prnCurrentColor;
3677: prnBitmap[i + 3 * ix * 3 * iy] &= (byte) prnCurrentColor;
3678: prnBitmap[i + 4 * ix * 3 * iy] &= (byte) prnCurrentColor;
3679: prnBitmap[i + 5 * ix * 3 * iy] &= (byte) prnCurrentColor;
3680: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
3681: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
3682: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
3683: prnBitmap[i + 3 * ix + 4 * iy] &= (byte) prnCurrentColor;
3684: prnBitmap[i + 4 * ix + 4 * iy] &= (byte) prnCurrentColor;
3685: prnBitmap[i + 5 * ix + 4 * iy] &= (byte) prnCurrentColor;
3686: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
3687: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
3688: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
3689: prnBitmap[i + 3 * ix + 5 * iy] &= (byte) prnCurrentColor;
3690: prnBitmap[i + 4 * ix + 5 * iy] &= (byte) prnCurrentColor;
3691: prnBitmap[i + 5 * ix + 5 * iy] &= (byte) prnCurrentColor;
3692: }
3693: i += 6 * ix;
3694: }
3695: bi += 6 * iy;
3696: }
3697: } else {
3698: for (int ay = 0; ay < ah; ay++) {
3699: for (int ax = 0; ax < aw; ax++) {
3700: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3701: prnPaintDot (6 * ax , 6 * ay );
3702: prnPaintDot (6 * ax + 1, 6 * ay );
3703: prnPaintDot (6 * ax + 2, 6 * ay );
3704: prnPaintDot (6 * ax + 3, 6 * ay );
3705: prnPaintDot (6 * ax + 4, 6 * ay );
3706: prnPaintDot (6 * ax + 5, 6 * ay );
3707: prnPaintDot (6 * ax , 6 * ay + 1);
3708: prnPaintDot (6 * ax + 1, 6 * ay + 1);
3709: prnPaintDot (6 * ax + 2, 6 * ay + 1);
3710: prnPaintDot (6 * ax + 3, 6 * ay + 1);
3711: prnPaintDot (6 * ax + 4, 6 * ay + 1);
3712: prnPaintDot (6 * ax + 5, 6 * ay + 1);
3713: prnPaintDot (6 * ax , 6 * ay + 2);
3714: prnPaintDot (6 * ax + 1, 6 * ay + 2);
3715: prnPaintDot (6 * ax + 2, 6 * ay + 2);
3716: prnPaintDot (6 * ax + 3, 6 * ay + 2);
3717: prnPaintDot (6 * ax + 4, 6 * ay + 2);
3718: prnPaintDot (6 * ax + 5, 6 * ay + 2);
3719: prnPaintDot (6 * ax , 6 * ay + 3);
3720: prnPaintDot (6 * ax + 1, 6 * ay + 3);
3721: prnPaintDot (6 * ax + 2, 6 * ay + 3);
3722: prnPaintDot (6 * ax + 3, 6 * ay + 3);
3723: prnPaintDot (6 * ax + 4, 6 * ay + 3);
3724: prnPaintDot (6 * ax + 5, 6 * ay + 3);
3725: prnPaintDot (6 * ax , 6 * ay + 4);
3726: prnPaintDot (6 * ax + 1, 6 * ay + 4);
3727: prnPaintDot (6 * ax + 2, 6 * ay + 4);
3728: prnPaintDot (6 * ax + 3, 6 * ay + 4);
3729: prnPaintDot (6 * ax + 4, 6 * ay + 4);
3730: prnPaintDot (6 * ax + 5, 6 * ay + 4);
3731: prnPaintDot (6 * ax , 6 * ay + 5);
3732: prnPaintDot (6 * ax + 1, 6 * ay + 5);
3733: prnPaintDot (6 * ax + 2, 6 * ay + 5);
3734: prnPaintDot (6 * ax + 3, 6 * ay + 5);
3735: prnPaintDot (6 * ax + 4, 6 * ay + 5);
3736: prnPaintDot (6 * ax + 5, 6 * ay + 5);
3737: }
3738: }
3739: }
3740: }
3741: prnHeadX += 6 * aw;
3742: }
3743: }
3744:
3745: prnPrinted = true;
3746:
3747: if (prnCanvas != null) {
3748: prnCanvas.repaint ();
3749: }
3750: }
3751:
3752:
3753:
3754:
3755:
3756:
3757:
3758:
3759: public static void prn24DotBitImage (byte[] a, int o, int n) {
3760: if (prnCurrentPaper == null) {
3761: prnFeedPaper ();
3762: }
3763:
3764: if (prnLineHeight == 45) {
3765: prnLineHeight = 48;
3766: }
3767: if (!prnHorizontalDoubleSizeMode) {
3768: if (!prnVerticalDoubleSizeMode) {
3769:
3770: int aw = n;
3771: int ah = 24;
3772: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
3773: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
3774: int bi = prnCheckRect (2 * aw, 2 * ah);
3775: if (0 <= bi) {
3776: int ix = prnIncrementX;
3777: int iy = prnIncrementY;
3778: for (int ay = 0; ay < ah; ay++) {
3779: int i = bi;
3780: for (int ax = 0; ax < aw; ax++) {
3781: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3782: prnBitmap[i ] &= (byte) prnCurrentColor;
3783: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3784: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3785: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3786: }
3787: i += 2 * ix;
3788: }
3789: bi += 2 * iy;
3790: }
3791: } else {
3792: for (int ay = 0; ay < ah; ay++) {
3793: for (int ax = 0; ax < aw; ax++) {
3794: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3795: prnPaintDot (2 * ax , 2 * ay );
3796: prnPaintDot (2 * ax + 1, 2 * ay );
3797: prnPaintDot (2 * ax , 2 * ay + 1);
3798: prnPaintDot (2 * ax + 1, 2 * ay + 1);
3799: }
3800: }
3801: }
3802: }
3803: prnHeadX += 2 * aw;
3804: } else {
3805:
3806: int aw = n;
3807: int ah = 24;
3808: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
3809: ah = Math.min (4 * ah, prnContentBottomY - prnHeadY) >> 2;
3810: int bi = prnCheckRect (2 * aw, 4 * ah);
3811: if (0 <= bi) {
3812: int ix = prnIncrementX;
3813: int iy = prnIncrementY;
3814: for (int ay = 0; ay < ah; ay++) {
3815: int i = bi;
3816: for (int ax = 0; ax < aw; ax++) {
3817: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3818: prnBitmap[i ] &= (byte) prnCurrentColor;
3819: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3820: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3821: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3822: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3823: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3824: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3825: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3826: }
3827: i += 2 * ix;
3828: }
3829: bi += 4 * iy;
3830: }
3831: } else {
3832: for (int ay = 0; ay < ah; ay++) {
3833: for (int ax = 0; ax < aw; ax++) {
3834: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3835: prnPaintDot (2 * ax , 4 * ay );
3836: prnPaintDot (2 * ax + 1, 4 * ay );
3837: prnPaintDot (2 * ax , 4 * ay + 1);
3838: prnPaintDot (2 * ax + 1, 4 * ay + 1);
3839: prnPaintDot (2 * ax , 4 * ay + 2);
3840: prnPaintDot (2 * ax + 1, 4 * ay + 2);
3841: prnPaintDot (2 * ax , 4 * ay + 3);
3842: prnPaintDot (2 * ax + 1, 4 * ay + 3);
3843: }
3844: }
3845: }
3846: }
3847: prnHeadX += 2 * aw;
3848: }
3849: } else {
3850: if (!prnVerticalDoubleSizeMode) {
3851:
3852: int aw = n;
3853: int ah = 24;
3854: aw = Math.min (4 * aw, prnMarginRightX - prnHeadX) >> 2;
3855: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
3856: int bi = prnCheckRect (4 * aw, 2 * ah);
3857: if (0 <= bi) {
3858: int ix = prnIncrementX;
3859: int iy = prnIncrementY;
3860: for (int ay = 0; ay < ah; ay++) {
3861: int i = bi;
3862: for (int ax = 0; ax < aw; ax++) {
3863: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3864: prnBitmap[i ] &= (byte) prnCurrentColor;
3865: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3866: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3867: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3868: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3869: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3870: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3871: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3872: }
3873: i += 4 * ix;
3874: }
3875: bi += 2 * iy;
3876: }
3877: } else {
3878: for (int ay = 0; ay < ah; ay++) {
3879: for (int ax = 0; ax < aw; ax++) {
3880: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3881: prnPaintDot (4 * ax , 2 * ay );
3882: prnPaintDot (4 * ax + 1, 2 * ay );
3883: prnPaintDot (4 * ax + 2, 2 * ay );
3884: prnPaintDot (4 * ax + 3, 2 * ay );
3885: prnPaintDot (4 * ax , 2 * ay + 1);
3886: prnPaintDot (4 * ax + 1, 2 * ay + 1);
3887: prnPaintDot (4 * ax + 2, 2 * ay + 1);
3888: prnPaintDot (4 * ax + 3, 2 * ay + 1);
3889: }
3890: }
3891: }
3892: }
3893: prnHeadX += 4 * aw;
3894: } else {
3895:
3896: int aw = n;
3897: int ah = 24;
3898: aw = Math.min (4 * aw, prnMarginRightX - prnHeadX) >> 2;
3899: ah = Math.min (4 * ah, prnContentBottomY - prnHeadY) >> 2;
3900: int bi = prnCheckRect (4 * aw, 4 * ah);
3901: if (0 <= bi) {
3902: int ix = prnIncrementX;
3903: int iy = prnIncrementY;
3904: for (int ay = 0; ay < ah; ay++) {
3905: int i = bi;
3906: for (int ax = 0; ax < aw; ax++) {
3907: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3908: prnBitmap[i ] &= (byte) prnCurrentColor;
3909: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3910: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3911: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3912: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3913: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3914: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3915: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3916: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3917: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3918: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3919: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
3920: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3921: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3922: prnBitmap[i + 2 * ix + 3 * iy] &= (byte) prnCurrentColor;
3923: prnBitmap[i + 3 * ix + 3 * iy] &= (byte) prnCurrentColor;
3924: }
3925: i += 4 * ix;
3926: }
3927: bi += 4 * iy;
3928: }
3929: } else {
3930: for (int ay = 0; ay < ah; ay++) {
3931: for (int ax = 0; ax < aw; ax++) {
3932: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3933: prnPaintDot (4 * ax , 4 * ay );
3934: prnPaintDot (4 * ax + 1, 4 * ay );
3935: prnPaintDot (4 * ax + 2, 4 * ay );
3936: prnPaintDot (4 * ax + 3, 4 * ay );
3937: prnPaintDot (4 * ax , 4 * ay + 1);
3938: prnPaintDot (4 * ax + 1, 4 * ay + 1);
3939: prnPaintDot (4 * ax + 2, 4 * ay + 1);
3940: prnPaintDot (4 * ax + 3, 4 * ay + 1);
3941: prnPaintDot (4 * ax , 4 * ay + 2);
3942: prnPaintDot (4 * ax + 1, 4 * ay + 2);
3943: prnPaintDot (4 * ax + 2, 4 * ay + 2);
3944: prnPaintDot (4 * ax + 3, 4 * ay + 2);
3945: prnPaintDot (4 * ax , 4 * ay + 3);
3946: prnPaintDot (4 * ax + 1, 4 * ay + 3);
3947: prnPaintDot (4 * ax + 2, 4 * ay + 3);
3948: prnPaintDot (4 * ax + 3, 4 * ay + 3);
3949: }
3950: }
3951: }
3952: }
3953: prnHeadX += 4 * aw;
3954: }
3955: }
3956:
3957: prnPrinted = true;
3958:
3959: if (prnCanvas != null) {
3960: prnCanvas.repaint ();
3961: }
3962: }
3963:
3964:
3965:
3966:
3967:
3968: public static void prnSetKanjiMode (boolean b) {
3969: prnKanjiMode = b;
3970: }
3971:
3972:
3973:
3974:
3975:
3976:
3977:
3978:
3979:
3980: public static void prnSetLeftMargin (int n) {
3981: if (prnCurrentPaper == null) {
3982: prnFeedPaper ();
3983: }
3984: if (0 <= n && n <= 999) {
3985: int leftX = prnGetCharacterWidth () * n;
3986: if (leftX < prnMarginRightX) {
3987: prnMarginLeftX = leftX;
3988: if (prnHeadX < prnMarginLeftX) {
3989: prnHeadX = prnMarginLeftX;
3990: }
3991:
3992: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3993: prnHorizontalTabAnchor[k] = 0;
3994: }
3995: }
3996: }
3997: }
3998:
3999:
4000:
4001:
4002:
4003:
4004:
4005: public static void prn48DotBitImage (byte[] a, int o, int n) {
4006: if (prnCurrentPaper == null) {
4007: prnFeedPaper ();
4008: }
4009:
4010: if (prnLineHeight == 45) {
4011: prnLineHeight = 47;
4012: }
4013: if (!prnHorizontalDoubleSizeMode) {
4014: if (!prnVerticalDoubleSizeMode) {
4015:
4016: int aw = n;
4017: int ah = 48;
4018: aw = Math.min (aw, prnMarginRightX - prnHeadX);
4019: ah = Math.min (ah, prnContentBottomY - prnHeadY);
4020: int bi = prnCheckRect ( aw, ah);
4021: if (0 <= bi) {
4022: int ix = prnIncrementX;
4023: int iy = prnIncrementY;
4024: for (int ay = 0; ay < ah; ay++) {
4025: int i = bi;
4026: for (int ax = 0; ax < aw; ax++) {
4027: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4028: prnBitmap[i ] &= (byte) prnCurrentColor;
4029: }
4030: i += ix;
4031: }
4032: bi += iy;
4033: }
4034: } else {
4035: for (int ay = 0; ay < ah; ay++) {
4036: for (int ax = 0; ax < aw; ax++) {
4037: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4038: prnPaintDot ( ax , ay );
4039: }
4040: }
4041: }
4042: }
4043: prnHeadX += aw;
4044: } else {
4045:
4046: int aw = n;
4047: int ah = 48;
4048: aw = Math.min (aw, prnMarginRightX - prnHeadX);
4049: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
4050: int bi = prnCheckRect ( aw, 2 * ah);
4051: if (0 <= bi) {
4052: int ix = prnIncrementX;
4053: int iy = prnIncrementY;
4054: for (int ay = 0; ay < ah; ay++) {
4055: int i = bi;
4056: for (int ax = 0; ax < aw; ax++) {
4057: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4058: prnBitmap[i ] &= (byte) prnCurrentColor;
4059: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4060: }
4061: i += ix;
4062: }
4063: bi += 2 * iy;
4064: }
4065: } else {
4066: for (int ay = 0; ay < ah; ay++) {
4067: for (int ax = 0; ax < aw; ax++) {
4068: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4069: prnPaintDot ( ax , 2 * ay );
4070: prnPaintDot ( ax , 2 * ay + 1);
4071: }
4072: }
4073: }
4074: }
4075: prnHeadX += aw;
4076: }
4077: } else {
4078: if (!prnVerticalDoubleSizeMode) {
4079:
4080: int aw = n;
4081: int ah = 48;
4082: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
4083: ah = Math.min (ah, prnContentBottomY - prnHeadY);
4084: int bi = prnCheckRect (2 * aw, ah);
4085: if (0 <= bi) {
4086: int ix = prnIncrementX;
4087: int iy = prnIncrementY;
4088: for (int ay = 0; ay < ah; ay++) {
4089: int i = bi;
4090: for (int ax = 0; ax < aw; ax++) {
4091: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4092: prnBitmap[i ] &= (byte) prnCurrentColor;
4093: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4094: }
4095: i += 2 * ix;
4096: }
4097: bi += iy;
4098: }
4099: } else {
4100: for (int ay = 0; ay < ah; ay++) {
4101: for (int ax = 0; ax < aw; ax++) {
4102: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4103: prnPaintDot (2 * ax , ay );
4104: prnPaintDot (2 * ax + 1, ay );
4105: }
4106: }
4107: }
4108: }
4109: prnHeadX += 2 * aw;
4110: } else {
4111:
4112: int aw = n;
4113: int ah = 24;
4114: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
4115: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
4116: int bi = prnCheckRect (2 * aw, 2 * ah);
4117: if (0 <= bi) {
4118: int ix = prnIncrementX;
4119: int iy = prnIncrementY;
4120: for (int ay = 0; ay < ah; ay++) {
4121: int i = bi;
4122: for (int ax = 0; ax < aw; ax++) {
4123: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4124: prnBitmap[i ] &= (byte) prnCurrentColor;
4125: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4126: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4127: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4128: }
4129: i += 2 * ix;
4130: }
4131: bi += 2 * iy;
4132: }
4133: } else {
4134: for (int ay = 0; ay < ah; ay++) {
4135: for (int ax = 0; ax < aw; ax++) {
4136: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4137: prnPaintDot (2 * ax , 2 * ay );
4138: prnPaintDot (2 * ax + 1, 2 * ay );
4139: prnPaintDot (2 * ax , 2 * ay + 1);
4140: prnPaintDot (2 * ax + 1, 2 * ay + 1);
4141: }
4142: }
4143: }
4144: }
4145: prnHeadX += 2 * aw;
4146: }
4147: }
4148:
4149: prnPrinted = true;
4150:
4151: if (prnCanvas != null) {
4152: prnCanvas.repaint ();
4153: }
4154: }
4155:
4156:
4157:
4158:
4159:
4160: public static void prnRepeatCharacter (int n, int d) {
4161: if (prnCurrentPaper == null) {
4162: prnFeedPaper ();
4163: }
4164: if (0x20 <= d) {
4165: for (int i = 0; i < n; i++) {
4166: prnPrintCharacter (d);
4167: }
4168: }
4169: }
4170:
4171:
4172:
4173:
4174: public static void prnSetSmallCharacterMode () {
4175: prnCharacterType = PRN_SMALL;
4176: }
4177:
4178:
4179:
4180:
4181:
4182: public static void prnSetPicaCharacterMode () {
4183: prnCharacterType = PRN_PICA;
4184: }
4185:
4186:
4187:
4188: public static void prnRepeat8DotBitImage (int n, int d) {
4189: if (prnCurrentPaper == null) {
4190: prnFeedPaper ();
4191: }
4192:
4193: }
4194:
4195:
4196:
4197: public static void prnRepeat16DotBitImage (int n, int d) {
4198: if (prnCurrentPaper == null) {
4199: prnFeedPaper ();
4200: }
4201:
4202: if (prnLineHeight == 45) {
4203: prnLineHeight = 48;
4204: }
4205: if (!prnHorizontalDoubleSizeMode) {
4206: if (!prnVerticalDoubleSizeMode) {
4207:
4208: int aw = n;
4209: int ah = 16;
4210: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
4211: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
4212: int bi = prnCheckRect (3 * aw, 3 * ah);
4213: if (0 <= bi) {
4214: int ix = prnIncrementX;
4215: int iy = prnIncrementY;
4216: for (int ay = 0; ay < ah; ay++) {
4217: int i = bi;
4218: for (int ax = 0; ax < aw; ax++) {
4219: if ((d >> (~ay & 15) & 1) != 0) {
4220: prnBitmap[i ] &= (byte) prnCurrentColor;
4221: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4222: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4223: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4224: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4225: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4226: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4227: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4228: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4229: }
4230: i += 3 * ix;
4231: }
4232: bi += 3 * iy;
4233: }
4234: } else {
4235: for (int ay = 0; ay < ah; ay++) {
4236: for (int ax = 0; ax < aw; ax++) {
4237: if ((d >> (~ay & 15) & 1) != 0) {
4238: prnPaintDot (3 * ax , 3 * ay );
4239: prnPaintDot (3 * ax + 1, 3 * ay );
4240: prnPaintDot (3 * ax + 2, 3 * ay );
4241: prnPaintDot (3 * ax , 3 * ay + 1);
4242: prnPaintDot (3 * ax + 1, 3 * ay + 1);
4243: prnPaintDot (3 * ax + 2, 3 * ay + 1);
4244: prnPaintDot (3 * ax , 3 * ay + 2);
4245: prnPaintDot (3 * ax + 1, 3 * ay + 2);
4246: prnPaintDot (3 * ax + 2, 3 * ay + 2);
4247: }
4248: }
4249: }
4250: }
4251: prnHeadX += 3 * aw;
4252: } else {
4253:
4254: int aw = n;
4255: int ah = 16;
4256: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
4257: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
4258: int bi = prnCheckRect (3 * aw, 6 * ah);
4259: if (0 <= bi) {
4260: int ix = prnIncrementX;
4261: int iy = prnIncrementY;
4262: for (int ay = 0; ay < ah; ay++) {
4263: int i = bi;
4264: for (int ax = 0; ax < aw; ax++) {
4265: if ((d >> (~ay & 15) & 1) != 0) {
4266: prnBitmap[i ] &= (byte) prnCurrentColor;
4267: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4268: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4269: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4270: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4271: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4272: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4273: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4274: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4275: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
4276: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
4277: prnBitmap[i + 2 * ix + 3 * iy] &= (byte) prnCurrentColor;
4278: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
4279: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
4280: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
4281: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
4282: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
4283: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
4284: }
4285: i += 3 * ix;
4286: }
4287: bi += 6 * iy;
4288: }
4289: } else {
4290: for (int ay = 0; ay < ah; ay++) {
4291: for (int ax = 0; ax < aw; ax++) {
4292: if ((d >> (~ay & 15) & 1) != 0) {
4293: prnPaintDot (3 * ax , 6 * ay );
4294: prnPaintDot (3 * ax + 1, 6 * ay );
4295: prnPaintDot (3 * ax + 2, 6 * ay );
4296: prnPaintDot (3 * ax , 6 * ay + 1);
4297: prnPaintDot (3 * ax + 1, 6 * ay + 1);
4298: prnPaintDot (3 * ax + 2, 6 * ay + 1);
4299: prnPaintDot (3 * ax , 6 * ay + 2);
4300: prnPaintDot (3 * ax + 1, 6 * ay + 2);
4301: prnPaintDot (3 * ax + 2, 6 * ay + 2);
4302: prnPaintDot (3 * ax , 6 * ay + 3);
4303: prnPaintDot (3 * ax + 1, 6 * ay + 3);
4304: prnPaintDot (3 * ax + 2, 6 * ay + 3);
4305: prnPaintDot (3 * ax , 6 * ay + 4);
4306: prnPaintDot (3 * ax + 1, 6 * ay + 4);
4307: prnPaintDot (3 * ax + 2, 6 * ay + 4);
4308: prnPaintDot (3 * ax , 6 * ay + 5);
4309: prnPaintDot (3 * ax + 1, 6 * ay + 5);
4310: prnPaintDot (3 * ax + 2, 6 * ay + 5);
4311: }
4312: }
4313: }
4314: }
4315: prnHeadX += 3 * aw;
4316: }
4317: } else {
4318: if (!prnVerticalDoubleSizeMode) {
4319:
4320: int aw = n;
4321: int ah = 16;
4322: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
4323: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
4324: int bi = prnCheckRect (6 * aw, 3 * ah);
4325: if (0 <= bi) {
4326: int ix = prnIncrementX;
4327: int iy = prnIncrementY;
4328: for (int ay = 0; ay < ah; ay++) {
4329: int i = bi;
4330: for (int ax = 0; ax < aw; ax++) {
4331: if ((d >> (~ay & 15) & 1) != 0) {
4332: prnBitmap[i ] &= (byte) prnCurrentColor;
4333: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4334: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4335: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
4336: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
4337: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
4338: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4339: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4340: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4341: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
4342: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
4343: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
4344: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4345: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4346: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4347: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
4348: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
4349: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
4350: }
4351: i += 6 * ix;
4352: }
4353: bi += 3 * iy;
4354: }
4355: } else {
4356: for (int ay = 0; ay < ah; ay++) {
4357: for (int ax = 0; ax < aw; ax++) {
4358: if ((d >> (~ay & 15) & 1) != 0) {
4359: prnPaintDot (6 * ax , 3 * ay );
4360: prnPaintDot (6 * ax + 1, 3 * ay );
4361: prnPaintDot (6 * ax + 2, 3 * ay );
4362: prnPaintDot (6 * ax + 3, 3 * ay );
4363: prnPaintDot (6 * ax + 4, 3 * ay );
4364: prnPaintDot (6 * ax + 5, 3 * ay );
4365: prnPaintDot (6 * ax , 3 * ay + 1);
4366: prnPaintDot (6 * ax + 1, 3 * ay + 1);
4367: prnPaintDot (6 * ax + 2, 3 * ay + 1);
4368: prnPaintDot (6 * ax + 3, 3 * ay + 1);
4369: prnPaintDot (6 * ax + 4, 3 * ay + 1);
4370: prnPaintDot (6 * ax + 5, 3 * ay + 1);
4371: prnPaintDot (6 * ax , 3 * ay + 2);
4372: prnPaintDot (6 * ax + 1, 3 * ay + 2);
4373: prnPaintDot (6 * ax + 2, 3 * ay + 2);
4374: prnPaintDot (6 * ax + 3, 3 * ay + 2);
4375: prnPaintDot (6 * ax + 4, 3 * ay + 2);
4376: prnPaintDot (6 * ax + 5, 3 * ay + 2);
4377: }
4378: }
4379: }
4380: }
4381: prnHeadX += 6 * aw;
4382: } else {
4383:
4384: int aw = n;
4385: int ah = 16;
4386: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
4387: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
4388: int bi = prnCheckRect (6 * aw, 6 * ah);
4389: if (0 <= bi) {
4390: int ix = prnIncrementX;
4391: int iy = prnIncrementY;
4392: for (int ay = 0; ay < ah; ay++) {
4393: int i = bi;
4394: for (int ax = 0; ax < aw; ax++) {
4395: if ((short) (d << (ay & 15)) < 0) {
4396: prnBitmap[i ] &= (byte) prnCurrentColor;
4397: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4398: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4399: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
4400: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
4401: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
4402: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4403: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4404: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4405: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
4406: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
4407: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
4408: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4409: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4410: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4411: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
4412: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
4413: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
4414: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
4415: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
4416: prnBitmap[i + 2 * ix + 3 * iy] &= (byte) prnCurrentColor;
4417: prnBitmap[i + 3 * ix + 3 * iy] &= (byte) prnCurrentColor;
4418: prnBitmap[i + 4 * ix + 3 * iy] &= (byte) prnCurrentColor;
4419: prnBitmap[i + 5 * ix + 3 * iy] &= (byte) prnCurrentColor;
4420: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
4421: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
4422: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
4423: prnBitmap[i + 3 * ix + 4 * iy] &= (byte) prnCurrentColor;
4424: prnBitmap[i + 4 * ix + 4 * iy] &= (byte) prnCurrentColor;
4425: prnBitmap[i + 5 * ix + 4 * iy] &= (byte) prnCurrentColor;
4426: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
4427: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
4428: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
4429: prnBitmap[i + 3 * ix + 5 * iy] &= (byte) prnCurrentColor;
4430: prnBitmap[i + 4 * ix + 5 * iy] &= (byte) prnCurrentColor;
4431: prnBitmap[i + 5 * ix + 5 * iy] &= (byte) prnCurrentColor;
4432: }
4433: i += 6 * ix;
4434: }
4435: bi += 6 * iy;
4436: }
4437: } else {
4438: for (int ay = 0; ay < ah; ay++) {
4439: for (int ax = 0; ax < aw; ax++) {
4440: if ((short) (d << (ay & 15)) < 0) {
4441: prnPaintDot (6 * ax , 6 * ay );
4442: prnPaintDot (6 * ax + 1, 6 * ay );
4443: prnPaintDot (6 * ax + 2, 6 * ay );
4444: prnPaintDot (6 * ax + 3, 6 * ay );
4445: prnPaintDot (6 * ax + 4, 6 * ay );
4446: prnPaintDot (6 * ax + 5, 6 * ay );
4447: prnPaintDot (6 * ax , 6 * ay + 1);
4448: prnPaintDot (6 * ax + 1, 6 * ay + 1);
4449: prnPaintDot (6 * ax + 2, 6 * ay + 1);
4450: prnPaintDot (6 * ax + 3, 6 * ay + 1);
4451: prnPaintDot (6 * ax + 4, 6 * ay + 1);
4452: prnPaintDot (6 * ax + 5, 6 * ay + 1);
4453: prnPaintDot (6 * ax , 6 * ay + 2);
4454: prnPaintDot (6 * ax + 1, 6 * ay + 2);
4455: prnPaintDot (6 * ax + 2, 6 * ay + 2);
4456: prnPaintDot (6 * ax + 3, 6 * ay + 2);
4457: prnPaintDot (6 * ax + 4, 6 * ay + 2);
4458: prnPaintDot (6 * ax + 5, 6 * ay + 2);
4459: prnPaintDot (6 * ax , 6 * ay + 3);
4460: prnPaintDot (6 * ax + 1, 6 * ay + 3);
4461: prnPaintDot (6 * ax + 2, 6 * ay + 3);
4462: prnPaintDot (6 * ax + 3, 6 * ay + 3);
4463: prnPaintDot (6 * ax + 4, 6 * ay + 3);
4464: prnPaintDot (6 * ax + 5, 6 * ay + 3);
4465: prnPaintDot (6 * ax , 6 * ay + 4);
4466: prnPaintDot (6 * ax + 1, 6 * ay + 4);
4467: prnPaintDot (6 * ax + 2, 6 * ay + 4);
4468: prnPaintDot (6 * ax + 3, 6 * ay + 4);
4469: prnPaintDot (6 * ax + 4, 6 * ay + 4);
4470: prnPaintDot (6 * ax + 5, 6 * ay + 4);
4471: prnPaintDot (6 * ax , 6 * ay + 5);
4472: prnPaintDot (6 * ax + 1, 6 * ay + 5);
4473: prnPaintDot (6 * ax + 2, 6 * ay + 5);
4474: prnPaintDot (6 * ax + 3, 6 * ay + 5);
4475: prnPaintDot (6 * ax + 4, 6 * ay + 5);
4476: prnPaintDot (6 * ax + 5, 6 * ay + 5);
4477: }
4478: }
4479: }
4480: }
4481: prnHeadX += 6 * aw;
4482: }
4483: }
4484:
4485: prnPrinted = true;
4486:
4487: if (prnCanvas != null) {
4488: prnCanvas.repaint ();
4489: }
4490: }
4491:
4492:
4493:
4494:
4495: public static void prnSetUnderlineMode (boolean b) {
4496: prnUnderlineMode = b;
4497: }
4498:
4499:
4500:
4501:
4502:
4503:
4504: public static void prnHorizontalMove (int n) {
4505: if (prnCurrentPaper == null) {
4506: prnFeedPaper ();
4507: }
4508: if (-1440 <= n && n <= 1440) {
4509: int headX = prnHeadX + 2 * n;
4510: if (prnMarginLeftX <= headX && headX < prnMarginRightX) {
4511: prnHeadX = headX;
4512: }
4513: }
4514: }
4515:
4516:
4517:
4518: public static void prnResetSettings () {
4519: prnEjectPaper ();
4520:
4521: prnMarginLeftX = 0;
4522: prnMarginRightX = 2879;
4523: prnMarginBottomHeight = 0;
4524:
4525: prnDefaultLineHeight = 60;
4526: prnLineHeight = 60;
4527:
4528: prnCharacterType = PRN_PICA;
4529:
4530: prnHiraganaMode = false;
4531:
4532: prnScriptMode = PRN_NO_SCRIPT;
4533:
4534: prnStrongMode = false;
4535:
4536: prnUnderlineMode = false;
4537:
4538: prnCharacterStyle = PRN_NORMAL_STYLE;
4539:
4540: prnKanjiMode = false;
4541:
4542: if (prnGaijiData != null) {
4543: Arrays.fill (prnGaijiData, (byte) 0);
4544: }
4545:
4546: prnVerticalWritingMode = false;
4547:
4548: prnFullWidthLeftSpace = 2;
4549: prnFullWidthRightSpace = 6;
4550: prnHalfWidthLeftSpace = 0;
4551: prnHalfWidthRightSpace = 4;
4552:
4553: prnHorizontalDoubleSizeMode = false;
4554: prnVerticalDoubleSizeMode = false;
4555: prnKanjiHorizontalDoubleSizeMode = false;
4556:
4557: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
4558: prnHorizontalTabAnchor[k] = 36 * 8 * (1 + k);
4559: }
4560:
4561: for (int k = 0; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
4562: prnVerticalTabAnchor[k] = 0;
4563: }
4564:
4565: prnColorMode = false;
4566:
4567: prnHalfWidthFont =
4568: prnFullWidthFont = (prnDIPSW & PRN_DIPSW_FONT_STYLE) == 0 ? 0 : 1;
4569:
4570: prnCurrentColor = prnSingleColor;
4571:
4572: prnCommandLength = 1;
4573: prnCommandPointer = 0;
4574: }
4575:
4576:
4577:
4578:
4579:
4580: public static void prnSetHalfWidthFont (int n) {
4581: if (0 <= n && n <= 1) {
4582: prnHalfWidthFont = n;
4583: }
4584: }
4585:
4586:
4587:
4588:
4589:
4590: public static void prnSenseOutOfPaper (boolean b) {
4591:
4592: }
4593:
4594:
4595:
4596:
4597:
4598:
4599:
4600: public static void prnSetCharacterStyle (int n) {
4601: if (0 <= n && n <= 3) {
4602: prnCharacterStyle = n;
4603: }
4604: }
4605:
4606:
4607:
4608:
4609:
4610: public static void prnSetScriptMode (int n) {
4611: if (0 <= n && n <= 2) {
4612: prnScriptMode = n;
4613: }
4614: }
4615:
4616:
4617:
4618:
4619: public static void prnSetVerticalWritingMode (boolean b) {
4620: prnVerticalWritingMode = b;
4621: }
4622:
4623:
4624:
4625: public static void prnSetFullWidthLeftRightSpace (int l, int r) {
4626: prnFullWidthLeftSpace = l;
4627: prnFullWidthRightSpace = r;
4628: }
4629:
4630:
4631:
4632: public static void prnSetHalfWidthLeftRightSpace (int l, int r) {
4633: prnHalfWidthLeftSpace = l;
4634: prnHalfWidthRightSpace = r;
4635: }
4636:
4637:
4638:
4639:
4640:
4641: public static void prnSetFullWidthFont (int n) {
4642: if (0 <= n && n <= 1) {
4643: prnFullWidthFont = n;
4644: }
4645: }
4646:
4647:
4648:
4649:
4650: public static void prnSetKanjiHorizontalDoubleSizeMode (boolean b) {
4651: prnKanjiHorizontalDoubleSizeMode = b;
4652: }
4653:
4654:
4655:
4656:
4657:
4658:
4659:
4660:
4661: public static int prnCheckRect (int rw, int rh) {
4662: int px0 = prnAliveLeftX + prnHeadX;
4663: int py0 = prnAliveTopY + prnHeadY;
4664: int px1 = px0 + rw - 1;
4665: int py1 = py0 + rh - 1;
4666: int bx0 = prnM11 * px0 + prnM12 * py0 + prnM13;
4667: int by0 = prnM21 * px0 + prnM22 * py0 + prnM23;
4668: int bx1 = prnM11 * px1 + prnM12 * py1 + prnM13;
4669: int by1 = prnM21 * px1 + prnM22 * py1 + prnM23;
4670: return (0 <= bx0 && bx0 < prnRotatedWidthDot &&
4671: 0 <= by0 && by0 < prnRotatedHeightDot &&
4672: 0 <= bx1 && bx1 < prnRotatedWidthDot &&
4673: 0 <= by1 && by1 < prnRotatedHeightDot ?
4674: bx0 + prnRotatedWidthDot * by0 :
4675: -1);
4676: }
4677:
4678:
4679:
4680:
4681:
4682: public static void prnPaintDot (int rx, int ry) {
4683: int px = prnAliveLeftX + prnHeadX + rx;
4684: int py = prnAliveTopY + prnHeadY + ry;
4685: int bx = prnM11 * px + prnM12 * py + prnM13;
4686: int by = prnM21 * px + prnM22 * py + prnM23;
4687: if (0 <= bx && bx < prnRotatedWidthDot &&
4688: 0 <= by && by < prnRotatedHeightDot) {
4689: prnBitmap[bx + prnRotatedWidthDot * by] &= (byte) prnCurrentColor;
4690: }
4691: }
4692:
4693:
4694:
4695:
4696:
4697: public static boolean prnSave () {
4698:
4699:
4700:
4701:
4702: int index = prnSaveName.lastIndexOf ('.');
4703: if (index < 0) {
4704: prnSaveName += ".png";
4705: index = prnSaveName.lastIndexOf ('.');
4706: }
4707: String full = prnSavePath + File.separator + prnSaveName;
4708: File imageFile = new File (full);
4709: if (imageFile.isFile ()) {
4710:
4711:
4712:
4713:
4714:
4715: if (!imageFile.canWrite ()) {
4716: XEiJ.pnlExitFullScreen (true);
4717: JOptionPane.showMessageDialog (
4718: null,
4719: full + (Multilingual.mlnJapanese ?
4720: "\nは既に存在します。上書きできません。" :
4721: "\nalreay exists. You cannot overwrite it."));
4722: return false;
4723: }
4724:
4725: XEiJ.pnlExitFullScreen (true);
4726: if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog (
4727: null,
4728: full + (Multilingual.mlnJapanese ?
4729: "\nは既に存在します。上書きしますか?" :
4730: "\nalreay exists. Do you want to overwrite it?"),
4731: Multilingual.mlnJapanese ? "ファイルの上書きの確認" : "Confirmation of overwriting file",
4732: JOptionPane.YES_NO_OPTION,
4733: JOptionPane.PLAIN_MESSAGE)) {
4734: return false;
4735: }
4736: }
4737: for (Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (prnSaveName.substring (index + 1));
4738:
4739: iterator.hasNext (); ) {
4740: ImageWriter imageWriter = iterator.next ();
4741: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
4742: if (false) {
4743: if (imageWriteParam.canWriteCompressed ()) {
4744: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
4745: imageWriteParam.setCompressionQuality (0.75F);
4746: }
4747: }
4748: IIOMetadata imageMetadata = imageWriter.getDefaultImageMetadata (
4749: ImageTypeSpecifier.createFromBufferedImageType (prnImage.getType ()),
4750: imageWriteParam);
4751: if (imageMetadata.isStandardMetadataFormatSupported ()) {
4752:
4753:
4754:
4755:
4756:
4757:
4758: IIOMetadataNode rootNode = new IIOMetadataNode ("javax_imageio_1.0");
4759: IIOMetadataNode dimensionNode = new IIOMetadataNode ("Dimension");
4760: IIOMetadataNode horizontalPixelSizeNode = new IIOMetadataNode("HorizontalPixelSize");
4761: IIOMetadataNode verticalPixelSizeNode = new IIOMetadataNode ("VerticalPixelSize");
4762: horizontalPixelSizeNode.setAttribute ("value", String.valueOf (360.0 / 25.4));
4763: verticalPixelSizeNode.setAttribute ("value", String.valueOf (360.0 / 25.4));
4764: dimensionNode.appendChild (horizontalPixelSizeNode);
4765: dimensionNode.appendChild (verticalPixelSizeNode);
4766: rootNode.appendChild (dimensionNode);
4767: try {
4768: imageMetadata.mergeTree ("javax_imageio_1.0", rootNode);
4769: } catch (IIOInvalidTreeException iioite) {
4770: continue;
4771: }
4772: imageFile.delete ();
4773: try (ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (imageFile)) {
4774: imageWriter.setOutput (imageOutputStream);
4775: imageWriter.write (imageMetadata, new IIOImage (prnImage, null, imageMetadata), imageWriteParam);
4776: } catch (IOException ioe) {
4777: continue;
4778: }
4779: return true;
4780: }
4781: }
4782: XEiJ.pnlExitFullScreen (true);
4783: JOptionPane.showMessageDialog (
4784: null,
4785: full + (Multilingual.mlnJapanese ?
4786: "\nを更新できませんでした。" :
4787: "\nwas not updated")
4788: );
4789: return false;
4790: }
4791:
4792:
4793:
4794: }
4795:
4796:
4797: