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: prnFrame.setVisible (true);
991: }
992:
993:
994:
995:
996: public static void prnMakeFrame () {
997:
998:
999: prnCanvas = new ScrollCanvas (prnImage);
1000: prnCanvas.setMargin (10, 10);
1001: prnCanvas.setMatColor (new Color (LnF.LNF_RGB[4]));
1002:
1003:
1004: ActionListener listener = new ActionListener () {
1005: @Override public void actionPerformed (ActionEvent ae) {
1006: Object source = ae.getSource ();
1007: String command = ae.getActionCommand ();
1008: switch (command) {
1009: case "Online":
1010: prnSetOnlineOn (((JCheckBoxMenuItem) source).isSelected ());
1011: break;
1012: case "Eject":
1013: if (PRN_USE_ADAPTER) {
1014:
1015: prnAdapterTimer.schedule (new PrinterAdapterTask (new byte[] { 0x1a, 0x0c }), 0L);
1016: }
1017: break;
1018: case "Destroy":
1019: if (PRN_USE_ADAPTER) {
1020:
1021: prnAdapterTimer.schedule (new PrinterAdapterTask (new byte[] { 0x1a, 0x1a, 0x1a, 0x0c }), 0L);
1022: }
1023: break;
1024: case "Reset":
1025: if (PRN_USE_ADAPTER) {
1026:
1027: prnAdapterTimer.schedule (new PrinterAdapterTask (new byte[] { 0x1a, 0x1a, 0x1b, 'c', '1' }), 0L);
1028: }
1029: break;
1030: case "Autosave":
1031: prnSetAutosaveOn (((JCheckBoxMenuItem) source).isSelected ());
1032: break;
1033: case "Close":
1034: prnFrame.setVisible (false);
1035: break;
1036:
1037: case "No margins":
1038: prnNextDeadTopMm = 0;
1039: prnNextDeadLeftMm = 0;
1040: prnNextDeadRightMm = 0;
1041: prnNextDeadBottomMm = 0;
1042: prnSpinnerLocked++;
1043: prnDeadTopModel.setValue (Integer.valueOf (prnNextDeadTopMm));
1044: prnDeadLeftModel.setValue (Integer.valueOf (prnNextDeadLeftMm));
1045: prnDeadRightModel.setValue (Integer.valueOf (prnNextDeadRightMm));
1046: prnDeadBottomModel.setValue (Integer.valueOf (prnNextDeadBottomMm));
1047: prnSpinnerLocked--;
1048: break;
1049: case "Reset margins":
1050: prnNextDeadTopMm = prnNextPaper.initialDeadTopMm;
1051: prnNextDeadLeftMm = prnNextPaper.initialDeadLeftMm;
1052: prnNextDeadRightMm = prnNextPaper.initialDeadRightMm;
1053: prnNextDeadBottomMm = prnNextPaper.initialDeadBottomMm;
1054: prnSpinnerLocked++;
1055: prnDeadTopModel.setValue (Integer.valueOf (prnNextDeadTopMm));
1056: prnDeadLeftModel.setValue (Integer.valueOf (prnNextDeadLeftMm));
1057: prnDeadRightModel.setValue (Integer.valueOf (prnNextDeadRightMm));
1058: prnDeadBottomModel.setValue (Integer.valueOf (prnNextDeadBottomMm));
1059: prnSpinnerLocked--;
1060: break;
1061: case "0°":
1062: prnNextRotation = 0;
1063: break;
1064: case "90°":
1065: prnNextRotation = 1;
1066: break;
1067: case "180°":
1068: prnNextRotation = 2;
1069: break;
1070: case "270°":
1071: prnNextRotation = 3;
1072: break;
1073: case "Dark mode":
1074: prnNextDarkMode = ((JCheckBoxMenuItem) source).isSelected ();
1075: break;
1076:
1077: case "Black ink ribbon":
1078: prnSetSingleColor (0);
1079: break;
1080: case "Blue ink ribbon":
1081: prnSetSingleColor (1);
1082: break;
1083: case "Lime ink ribbon":
1084: prnSetSingleColor (2);
1085: break;
1086: case "Cyan ink ribbon":
1087: prnSetSingleColor (3);
1088: break;
1089: case "Red ink ribbon":
1090: prnSetSingleColor (4);
1091: break;
1092: case "Magenta ink ribbon":
1093: prnSetSingleColor (5);
1094: break;
1095: case "Yellow ink ribbon":
1096: prnSetSingleColor (6);
1097: break;
1098: case "White ink ribbon":
1099: prnSetSingleColor (7);
1100: break;
1101:
1102: case "6.25%":
1103: prnCanvas.setScaleShift (-4);
1104: break;
1105: case "12.5%":
1106: prnCanvas.setScaleShift (-3);
1107: break;
1108: case "25%":
1109: prnCanvas.setScaleShift (-2);
1110: break;
1111: case "50%":
1112: prnCanvas.setScaleShift (-1);
1113: break;
1114: case "100%":
1115: prnCanvas.setScaleShift (0);
1116: break;
1117: case "200%":
1118: prnCanvas.setScaleShift (1);
1119: break;
1120: case "400%":
1121: prnCanvas.setScaleShift (2);
1122: break;
1123: case "800%":
1124: prnCanvas.setScaleShift (3);
1125: break;
1126: case "1600%":
1127: prnCanvas.setScaleShift (4);
1128: break;
1129:
1130: case "Roman / Mincho":
1131: prnDIPSW &= ~PRN_DIPSW_FONT_STYLE;
1132: break;
1133: case "Sans-Serif / Gothic":
1134: prnDIPSW |= PRN_DIPSW_FONT_STYLE;
1135: break;
1136:
1137: default:
1138: for (Paper paper : prnPaperArray) {
1139: if (paper.nameEn.equals (command)) {
1140: prnNextPaper = paper;
1141: prnNextDeadTopMm = Math.min (prnNextDeadTopMm, prnNextPaper.paperHeightMm - 1);
1142: prnNextDeadLeftMm = Math.min (prnNextDeadLeftMm, prnNextPaper.paperWidthMm - 1);
1143: prnNextDeadRightMm = Math.min (prnNextDeadRightMm, prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm);
1144: prnNextDeadBottomMm = Math.min (prnNextDeadBottomMm, prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm);
1145: prnSpinnerLocked++;
1146: prnDeadTopModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1));
1147: prnDeadLeftModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1));
1148: prnDeadRightModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm));
1149: prnDeadBottomModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm));
1150: prnDeadTopModel.setValue (Integer.valueOf (prnNextDeadTopMm));
1151: prnDeadLeftModel.setValue (Integer.valueOf (prnNextDeadLeftMm));
1152: prnDeadRightModel.setValue (Integer.valueOf (prnNextDeadRightMm));
1153: prnDeadBottomModel.setValue (Integer.valueOf (prnNextDeadBottomMm));
1154: prnSpinnerLocked--;
1155: break;
1156: }
1157: }
1158: }
1159: }
1160: };
1161:
1162:
1163: ButtonGroup paperGroup = new ButtonGroup ();
1164: JMenu portraitMenu = Multilingual.mlnText (ComponentFactory.createMenu ("Portrait", 'P'), "ja", "縦長");
1165: JMenu landscapeMenu = Multilingual.mlnText (ComponentFactory.createMenu ("Landscape", 'L'), "ja", "横長");
1166: for (int i = 0; i < prnPaperArray.length; i++) {
1167: Paper paper = prnPaperArray[i];
1168: (i < prnPaperArray.length >> 1 ? portraitMenu : landscapeMenu).add (
1169: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (
1170: paperGroup, paper == prnNextPaper, paper.nameEn, listener), "ja", paper.nameJa));
1171: }
1172:
1173: prnSpinnerLocked = 0;
1174: prnDeadTopModel = new SpinnerNumberModel (prnNextDeadTopMm, 0, prnNextPaper.paperHeightMm - 1, 1);
1175: prnDeadLeftModel = new SpinnerNumberModel (prnNextDeadLeftMm, 0, prnNextPaper.paperWidthMm - 1, 1);
1176: prnDeadRightModel = new SpinnerNumberModel (prnNextDeadRightMm, 0, prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm, 1);
1177: prnDeadBottomModel = new SpinnerNumberModel (prnNextDeadBottomMm, 0, prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm, 1);
1178: prnDeadTopSpinner = ComponentFactory.createNumberSpinner (prnDeadTopModel, 4, new ChangeListener () {
1179: @Override public void stateChanged (ChangeEvent ce) {
1180: if (prnSpinnerLocked == 0) {
1181: prnNextDeadTopMm = prnDeadTopModel.getNumber ().intValue ();
1182: prnDeadBottomModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1 - prnNextDeadTopMm));
1183: }
1184: }
1185: });
1186: prnDeadLeftSpinner = ComponentFactory.createNumberSpinner (prnDeadLeftModel, 4, new ChangeListener () {
1187: @Override public void stateChanged (ChangeEvent ce) {
1188: if (prnSpinnerLocked == 0) {
1189: prnNextDeadLeftMm = prnDeadLeftModel.getNumber ().intValue ();
1190: prnDeadRightModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1 - prnNextDeadLeftMm));
1191: }
1192: }
1193: });
1194: prnDeadRightSpinner = ComponentFactory.createNumberSpinner (prnDeadRightModel, 4, new ChangeListener () {
1195: @Override public void stateChanged (ChangeEvent ce) {
1196: if (prnSpinnerLocked == 0) {
1197: prnNextDeadRightMm = prnDeadRightModel.getNumber ().intValue ();
1198: prnDeadLeftModel.setMaximum (Integer.valueOf (prnNextPaper.paperWidthMm - 1 - prnNextDeadRightMm));
1199: }
1200: }
1201: });
1202: prnDeadBottomSpinner = ComponentFactory.createNumberSpinner (prnDeadBottomModel, 4, new ChangeListener () {
1203: @Override public void stateChanged (ChangeEvent ce) {
1204: if (prnSpinnerLocked == 0) {
1205: prnNextDeadBottomMm = prnDeadBottomModel.getNumber ().intValue ();
1206: prnDeadTopModel.setMaximum (Integer.valueOf (prnNextPaper.paperHeightMm - 1 - prnNextDeadBottomMm));
1207: }
1208: }
1209: });
1210:
1211:
1212: ButtonGroup ribbonGroup = new ButtonGroup ();
1213:
1214:
1215: ButtonGroup zoomGroup = new ButtonGroup ();
1216: prnScaleMenuItem = new JRadioButtonMenuItem[9];
1217: ButtonGroup directionGroup = new ButtonGroup ();
1218: ButtonGroup fontStyleGroup = new ButtonGroup ();
1219:
1220:
1221: JMenuBar menuBar = ComponentFactory.createMenuBar (
1222:
1223:
1224: Multilingual.mlnText (
1225: ComponentFactory.createMenu (
1226: "File", 'F',
1227: prnOnlineMenuItem =
1228: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (prnOnlineOn, "Online", listener), "ja", "オンライン"),
1229: ComponentFactory.createHorizontalSeparator (),
1230: !PRN_USE_ADAPTER ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("Eject", 'E', listener), "ja", "排紙"),
1231: !PRN_USE_ADAPTER ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("Destroy", 'D', listener), "ja", "破棄"),
1232: !PRN_USE_ADAPTER ? null : Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset", 'R', listener), "ja", "リセット"),
1233: ComponentFactory.createHorizontalSeparator (),
1234: prnAutosaveMenuItem =
1235: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (prnAutosaveOn, "Autosave", listener), "ja", "自動保存"),
1236: ComponentFactory.createHorizontalSeparator (),
1237: Multilingual.mlnText (ComponentFactory.createMenuItem ("Close", 'C', listener), "ja", "閉じる")
1238: ),
1239: "ja", "ファイル"),
1240:
1241:
1242: Multilingual.mlnText (
1243: ComponentFactory.createMenu (
1244: "Paper", 'P',
1245: portraitMenu,
1246: landscapeMenu,
1247: ComponentFactory.createHorizontalSeparator (),
1248: Multilingual.mlnText (
1249: ComponentFactory.createMenu (
1250: "Margin", 'M',
1251: ComponentFactory.createHorizontalBox (
1252: Box.createHorizontalGlue (),
1253: Multilingual.mlnText (ComponentFactory.createLabel ("Top "), "ja", "上 "),
1254: prnDeadTopSpinner,
1255: ComponentFactory.createLabel (" mm"),
1256: Box.createHorizontalGlue ()
1257: ),
1258: ComponentFactory.createHorizontalBox (
1259: Box.createHorizontalGlue (),
1260: Multilingual.mlnText (ComponentFactory.createLabel ("Left "), "ja", "左 "),
1261: prnDeadLeftSpinner,
1262: ComponentFactory.createLabel (" mm"),
1263: Box.createHorizontalStrut (20),
1264: Multilingual.mlnText (ComponentFactory.createLabel ("Right "), "ja", "右 "),
1265: prnDeadRightSpinner,
1266: ComponentFactory.createLabel (" mm"),
1267: Box.createHorizontalGlue ()
1268: ),
1269: ComponentFactory.createHorizontalBox (
1270: Box.createHorizontalGlue (),
1271: Multilingual.mlnText (ComponentFactory.createLabel ("Bottom "), "ja", "下 "),
1272: prnDeadBottomSpinner,
1273: ComponentFactory.createLabel (" mm"),
1274: Box.createHorizontalGlue ()
1275: ),
1276: ComponentFactory.createHorizontalSeparator (),
1277: Multilingual.mlnText (ComponentFactory.createMenuItem ("No margins", listener), "ja", "余白なし"),
1278: ComponentFactory.createHorizontalSeparator (),
1279: Multilingual.mlnText (ComponentFactory.createMenuItem ("Reset margins", listener), "ja", "初期値に戻す")
1280: ),
1281: "ja", "余白"),
1282: ComponentFactory.createHorizontalSeparator (),
1283: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 0, "0°", listener),
1284: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 1, "90°", listener),
1285: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 2, "180°", listener),
1286: ComponentFactory.createRadioButtonMenuItem (directionGroup, prnNextRotation == 3, "270°", listener),
1287: ComponentFactory.createHorizontalSeparator (),
1288: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (prnNextDarkMode, "Dark mode", listener), "ja", "ダークモード")
1289: ),
1290: "ja", "用紙"),
1291:
1292:
1293: Multilingual.mlnText (
1294: ComponentFactory.createMenu (
1295: "Ink ribbon", 'R',
1296: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 0,
1297: "Black ink ribbon", '0', listener),
1298: "ja", "黒色インクリボン"),
1299: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 1,
1300: "Blue ink ribbon", '1', listener),
1301: "ja", "青色インクリボン"),
1302: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 2,
1303: "Lime ink ribbon", '2', listener),
1304: "ja", "緑色インクリボン"),
1305: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 3,
1306: "Cyan ink ribbon", '3', listener),
1307: "ja", "水色インクリボン"),
1308: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 4,
1309: "Red ink ribbon", '4', listener),
1310: "ja", "赤色インクリボン"),
1311: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 5,
1312: "Magenta ink ribbon", '5', listener),
1313: "ja", "紫色インクリボン"),
1314: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 6,
1315: "Yellow ink ribbon", '6', listener),
1316: "ja", "黄色インクリボン"),
1317: Multilingual.mlnText (ComponentFactory.createRadioButtonMenuItem (ribbonGroup, prnSingleColor == 7,
1318: "White ink ribbon", '7', listener),
1319: "ja", "白色インクリボン")
1320: ),
1321: "ja", "インクリボン"),
1322:
1323:
1324: Multilingual.mlnText (
1325: ComponentFactory.createMenu (
1326: "Display", 'D',
1327: prnScaleMenuItem[0] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -4, "6.25%", '1', listener),
1328: prnScaleMenuItem[1] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -3, "12.5%", '2', listener),
1329: prnScaleMenuItem[2] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -2, "25%", '3', listener),
1330: prnScaleMenuItem[3] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == -1, "50%", '4', listener),
1331: prnScaleMenuItem[4] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 0, "100%", '5', listener),
1332: prnScaleMenuItem[5] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 1, "200%", '6', listener),
1333: prnScaleMenuItem[6] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 2, "400%", '7', listener),
1334: prnScaleMenuItem[7] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 3, "800%", '8', listener),
1335: prnScaleMenuItem[8] = ComponentFactory.createRadioButtonMenuItem (zoomGroup, prnScaleShift == 4, "1600%", '9', listener)
1336: ),
1337: "ja", "表示"),
1338:
1339:
1340: ComponentFactory.createMenu (
1341: "DIPSW", 'S',
1342: Multilingual.mlnText (
1343: ComponentFactory.createRadioButtonMenuItem (
1344: fontStyleGroup,
1345: (prnDIPSW & PRN_DIPSW_FONT_STYLE) == 0,
1346: "Roman / Mincho",
1347: listener
1348: ),
1349: "ja", "ローマン体/明朝体"
1350: ),
1351: Multilingual.mlnText (
1352: ComponentFactory.createRadioButtonMenuItem (
1353: fontStyleGroup,
1354: (prnDIPSW & PRN_DIPSW_FONT_STYLE) != 0,
1355: "Sans-Serif / Gothic",
1356: listener
1357: ),
1358: "ja", "サンセリフ体/ゴシック体"
1359: )
1360: )
1361:
1362: );
1363:
1364:
1365: prnCanvas.addScaleShiftListener (new ScrollCanvas.ScaleShiftListener () {
1366: @Override public void scaleShiftChanged (int scaleShift) {
1367: if (prnScaleShift != scaleShift &&
1368: -4 <= scaleShift && scaleShift <= 4) {
1369: prnScaleShift = scaleShift;
1370: prnScaleMenuItem[4 + scaleShift].setSelected (true);
1371: }
1372: }
1373: });
1374:
1375:
1376: prnFrame = Multilingual.mlnTitle (
1377: ComponentFactory.createRestorableSubFrame (
1378: Settings.SGS_PRN_FRAME_KEY,
1379: "Printer",
1380: menuBar,
1381: ComponentFactory.createBorderPanel (
1382: ComponentFactory.setPreferredSize (prnCanvas, 600, 400),
1383: null,
1384: null,
1385: null
1386: )
1387: ),
1388: "ja", "プリンタ");
1389:
1390: }
1391:
1392:
1393:
1394: public static void prnMakeSaveDialog () {
1395:
1396: prnWriterSuffixes = ImageIO.getWriterFileSuffixes ();
1397: if (XEiJ.prgCaseIgnored) {
1398: for (int i = 0; i < prnWriterSuffixes.length; i++) {
1399: prnWriterSuffixes[i] = prnWriterSuffixes[i].toLowerCase ();
1400: }
1401: }
1402:
1403: prnSaveFileFilter = new javax.swing.filechooser.FileFilter () {
1404: @Override public boolean accept (File file) {
1405: if (file.isDirectory ()) {
1406: return true;
1407: }
1408: String name = file.getName ();
1409: if (XEiJ.prgCaseIgnored) {
1410: name = name.toLowerCase ();
1411: }
1412: for (String suffix : prnWriterSuffixes) {
1413: if (name.endsWith ("." + suffix)) {
1414: return true;
1415: }
1416: }
1417: return false;
1418: }
1419: @Override public String getDescription () {
1420: return Multilingual.mlnJapanese ? "プリンタ出力イメージ" : "Printer Output Image";
1421: }
1422: };
1423:
1424: ActionListener listener = new ActionListener () {
1425: @Override public void actionPerformed (ActionEvent ae) {
1426: switch (ae.getActionCommand ()) {
1427: case JFileChooser.APPROVE_SELECTION:
1428: case "Save":
1429: {
1430: File file = prnSaveFileChooser.getSelectedFile ().getAbsoluteFile ();
1431: prnSavePath = file.getParentFile ().getAbsolutePath ();
1432: prnSaveName = file.getName ();
1433: }
1434: if (prnSave ()) {
1435:
1436:
1437: prnSaveDialog.setVisible (false);
1438: }
1439: break;
1440: case JFileChooser.CANCEL_SELECTION:
1441: case "Discard":
1442: prnSaveDialog.setVisible (false);
1443: break;
1444: case "Autosave from next time":
1445: prnSetAutosaveOn (prnAutosaveCheckBox.isSelected ());
1446: break;
1447: }
1448: }
1449: };
1450:
1451: prnSaveFileChooser = new JFileChooser2 (new File (prnSavePath + File.separator + prnSaveName));
1452: prnSaveFileChooser.setFileFilter (prnSaveFileFilter);
1453: prnSaveFileChooser.setMultiSelectionEnabled (false);
1454: prnSaveFileChooser.setControlButtonsAreShown (false);
1455: prnSaveFileChooser.addActionListener (listener);
1456:
1457: prnSaveDialog = Multilingual.mlnTitle (
1458: ComponentFactory.createModalDialog (
1459: XEiJ.frmFrame,
1460: "Save printer output image",
1461: ComponentFactory.createBorderPanel (
1462: 0, 0,
1463: ComponentFactory.createVerticalBox (
1464: prnSaveFileChooser,
1465: ComponentFactory.createHorizontalBox (
1466: Box.createHorizontalStrut (12),
1467: Box.createHorizontalGlue (),
1468: prnAutosaveCheckBox =
1469: Multilingual.mlnText (ComponentFactory.createCheckBox (prnAutosaveOn, "Autosave from next time", listener), "ja", "次回から自動保存"),
1470: Box.createHorizontalGlue (),
1471: Box.createHorizontalStrut (12),
1472: Multilingual.mlnText (ComponentFactory.createButton ("Save", KeyEvent.VK_S, listener), "ja", "保存"),
1473: Box.createHorizontalStrut (12),
1474: Multilingual.mlnText (ComponentFactory.createButton ("Discard", KeyEvent.VK_D, listener), "ja", "破棄"),
1475: Box.createHorizontalStrut (12)
1476: ),
1477: Box.createVerticalStrut (12)
1478: )
1479: )
1480: ),
1481: "ja", "プリンタ出力イメージの保存");
1482: }
1483:
1484:
1485:
1486: public static void prnSetAutosaveOn (boolean on) {
1487: if (prnAutosaveOn != on) {
1488: prnAutosaveOn = on;
1489: if (prnAutosaveCheckBox != null &&
1490: prnAutosaveCheckBox.isSelected () != prnAutosaveOn) {
1491: prnAutosaveCheckBox.setSelected (prnAutosaveOn);
1492: }
1493: if (prnAutosaveMenuItem != null &&
1494: prnAutosaveMenuItem.isSelected () != prnAutosaveOn) {
1495: prnAutosaveMenuItem.setSelected (prnAutosaveOn);
1496: }
1497: }
1498: }
1499:
1500:
1501:
1502:
1503:
1504:
1505:
1506: public static void prnReset () {
1507: prnData = 0;
1508: prnStrobe = 1;
1509: }
1510:
1511:
1512: public static int prnReadData () {
1513: return prnData;
1514: }
1515:
1516:
1517: public static int prnReadStrobe () {
1518: return prnStrobe;
1519: }
1520:
1521:
1522: public static void prnWriteData (int d) {
1523: prnData = d & 255;
1524: }
1525:
1526:
1527: public static void prnWriteStrobe (int d) {
1528: d &= 1;
1529: if (prnStrobe != d) {
1530: prnStrobe = d;
1531: if (prnOnlineOn) {
1532: if (d != 0) {
1533:
1534: IOInterrupt.ioiPrnFall ();
1535:
1536: if (PRN_USE_ADAPTER) {
1537: prnAdapterOutput (prnData);
1538: } else {
1539: prnOutput (prnData);
1540: }
1541:
1542: IOInterrupt.ioiPrnRise ();
1543: }
1544: }
1545: }
1546: }
1547:
1548:
1549:
1550: public static void prnSetOnlineOn (boolean on) {
1551: if (prnOnlineOn != on) {
1552: prnOnlineOn = on;
1553: if (prnOnlineMenuItem != null) {
1554: prnOnlineMenuItem.setSelected (on);
1555: }
1556: if (on) {
1557:
1558: IOInterrupt.ioiPrnRise ();
1559: } else {
1560:
1561: IOInterrupt.ioiPrnFall ();
1562: }
1563: }
1564: }
1565:
1566:
1567:
1568:
1569:
1570:
1571:
1572:
1573: public static void prnOutput (int x) {
1574: prnCommandBuffer[prnCommandPointer++] = (byte) x;
1575: if (prnCommandPointer < prnCommandLength) {
1576: return;
1577: }
1578: command:
1579: {
1580: int c = prnCommandBuffer[0] & 255;
1581: int d, e, f, g, h, i, j, z, n;
1582: switch (c) {
1583: case 0x08:
1584: prnPrintBackSpace ();
1585: break command;
1586: case 0x09:
1587: prnPrintHorizontalTab ();
1588: break command;
1589: case 0x0a:
1590: prnPrintLineFeed (1);
1591: break command;
1592: case 0x0b:
1593: if (prnCommandLength < 2) {
1594: prnCommandLength = 2;
1595: return;
1596: }
1597: d = prnCommandBuffer[1] & 255;
1598: prnPrintVerticalTab (d & 15);
1599: break command;
1600: case 0x0c:
1601: prnPrintFormFeed ();
1602: break command;
1603: case 0x0d:
1604: prnPrintCarriageReturn ();
1605: break command;
1606: case 0x0e:
1607: prnSetHorizontalDoubleSizeMode (true);
1608: break command;
1609: case 0x0f:
1610: prnSetHorizontalDoubleSizeMode (false);
1611: break command;
1612: case 0x10:
1613: if (prnCommandLength < 4) {
1614: prnCommandLength = 4;
1615: return;
1616: }
1617: d = prnCommandBuffer[1] & 255;
1618: e = prnCommandBuffer[2] & 255;
1619: f = prnCommandBuffer[3] & 255;
1620: prnSetStartColumn ((d & 15) * 100 + (e & 15) * 10 + (f & 15));
1621: break command;
1622: case 0x11:
1623: prnSelect (true);
1624: break command;
1625: case 0x13:
1626: prnSelect (false);
1627: break command;
1628: case 0x14:
1629: z = prnCommandBuffer[prnCommandLength - 1] & 255;
1630: if (z != 0x3f) {
1631: if (prnCommandLength + 1 < prnCommandBuffer.length) {
1632: prnCommandLength++;
1633: }
1634: return;
1635: }
1636: prnSetVerticalTabAnchor (prnCommandBuffer, 1, prnCommandLength - 1);
1637: break command;
1638: case 0x18:
1639: prnCancel ();
1640: break command;
1641: case 0x1a:
1642: if (prnCommandLength < 2) {
1643: prnCommandLength = 2;
1644: return;
1645: }
1646: d = prnCommandBuffer[1] & 255;
1647: switch (d) {
1648: case 0x0c:
1649: prnEjectPaper ();
1650: break command;
1651: case 0x1a:
1652: prnErasePaper ();
1653: break command;
1654: case 0x56:
1655: prnSetVerticalDoubleSizeMode (true);
1656: break command;
1657: case 0x57:
1658: prnSetVerticalDoubleSizeMode (false);
1659: break command;
1660: }
1661: break;
1662: case 0x1b:
1663: if (prnCommandLength < 2) {
1664: prnCommandLength = 2;
1665: return;
1666: }
1667: d = prnCommandBuffer[1] & 255;
1668: switch (d) {
1669: case 0x00:
1670: case 0x01:
1671: case 0x02:
1672: case 0x03:
1673: case 0x04:
1674: case 0x05:
1675: case 0x06:
1676: prnHorizontalMove (d);
1677: break command;
1678: case 0x0b:
1679: if (prnCommandLength < 4) {
1680: prnCommandLength = 4;
1681: return;
1682: }
1683: e = prnCommandBuffer[2] & 255;
1684: f = prnCommandBuffer[3] & 255;
1685: prnPrintLineFeed ((e & 15) * 10 + (f & 15));
1686: break command;
1687: case 0x10:
1688: if (prnCommandLength < 6) {
1689: prnCommandLength = 6;
1690: return;
1691: }
1692: e = prnCommandBuffer[2] & 255;
1693: f = prnCommandBuffer[3] & 255;
1694: g = prnCommandBuffer[4] & 255;
1695: h = prnCommandBuffer[5] & 255;
1696: prnSetHorizontalStartPosition ((e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15));
1697: break command;
1698: case 0x19:
1699: prnSetColorMode ();
1700: break command;
1701: case 0x21:
1702: prnSetStrongMode (true);
1703: break command;
1704: case 0x22:
1705: prnSetStrongMode (false);
1706: break command;
1707: case 0x24:
1708: prnSetHiraganaMode (false);
1709: break command;
1710: case 0x25:
1711: if (prnCommandLength < 3) {
1712: prnCommandLength = 3;
1713: return;
1714: }
1715: e = prnCommandBuffer[2] & 255;
1716: switch (e) {
1717: case 0x32:
1718: if (prnCommandLength < 5) {
1719: prnCommandLength = 5;
1720: return;
1721: }
1722: f = prnCommandBuffer[3] & 255;
1723: g = prnCommandBuffer[4] & 255;
1724: n = f << 8 | g;
1725: if (prnCommandLength < 5 + n) {
1726: prnCommandLength = 5 + n;
1727: return;
1728: }
1729: prn8DotBitImage (prnCommandBuffer, 5, n);
1730: break command;
1731: case 0x39:
1732: if (prnCommandLength < 4) {
1733: prnCommandLength = 4;
1734: return;
1735: }
1736: f = prnCommandBuffer[3] & 255;
1737: prnSetLineHeight (f);
1738: break command;
1739: }
1740: break;
1741: case 0x26:
1742: prnSetHiraganaMode (true);
1743: break command;
1744: case 0x28:
1745: z = prnCommandBuffer[prnCommandLength - 1] & 255;
1746: if (z != 0x2e) {
1747: if (prnCommandLength + 1 < prnCommandBuffer.length) {
1748: prnCommandLength++;
1749: }
1750: return;
1751: }
1752: prnSetHorizontalTabAnchor (prnCommandBuffer, 2, prnCommandLength - 2);
1753: break command;
1754: case 0x29:
1755: z = prnCommandBuffer[prnCommandLength - 1] & 255;
1756: if (z != 0x2e) {
1757: if (prnCommandLength + 1 < prnCommandBuffer.length) {
1758: prnCommandLength++;
1759: }
1760: return;
1761: }
1762: prnClearHorizontalTabAnchor (prnCommandBuffer, 2, prnCommandLength - 2);
1763: break command;
1764: case 0x2a:
1765: if (prnCommandLength < 36) {
1766: prnCommandLength = 36;
1767: return;
1768: }
1769: prn16DotExtendedCharacterDefinition (prnCommandBuffer, 2, prnCommandLength - 2);
1770: break command;
1771: case 0x2b:
1772: if (prnCommandLength < 76) {
1773: prnCommandLength = 76;
1774: return;
1775: }
1776: prn24DotExtendedCharacterDefinition (prnCommandBuffer, 2, prnCommandLength - 2);
1777: break command;
1778: case 0x2f:
1779: if (prnCommandLength < 5) {
1780: prnCommandLength = 5;
1781: return;
1782: }
1783: e = prnCommandBuffer[2] & 255;
1784: f = prnCommandBuffer[3] & 255;
1785: g = prnCommandBuffer[4] & 255;
1786: prnSetRightMargin ((e & 15) * 100 + (f & 15) * 10 + (g & 15));
1787: break command;
1788: case 0x32:
1789: prnClearAllHorizontalTabAnchor ();
1790: break command;
1791: case 0x35:
1792: prnSetPageStartPosition ();
1793: break command;
1794: case 0x36:
1795: prnSetOneSixth ();
1796: break command;
1797: case 0x38:
1798: prnSetOneEighth ();
1799: break command;
1800: case 0x43:
1801: if (prnCommandLength < 4) {
1802: prnCommandLength = 4;
1803: return;
1804: }
1805: e = prnCommandBuffer[2] & 255;
1806: f = prnCommandBuffer[3] & 255;
1807: prnSetBottomMargin ((e & 15) * 10 + (f & 15));
1808: break command;
1809: case 0x45:
1810: prnSetEliteCharacterMode ();
1811: break command;
1812: case 0x46:
1813: if (prnCommandLength < 4) {
1814: prnCommandLength = 4;
1815: return;
1816: }
1817: e = prnCommandBuffer[2] & 255;
1818: f = prnCommandBuffer[3] & 255;
1819: prnSetPageHeight ((e & 15) * 10 + (f & 15));
1820: break command;
1821: case 0x48:
1822: prnSetKanjiMode (false);
1823: break command;
1824: case 0x49:
1825: if (prnCommandLength < 6) {
1826: prnCommandLength = 6;
1827: return;
1828: }
1829: e = prnCommandBuffer[2] & 255;
1830: f = prnCommandBuffer[3] & 255;
1831: g = prnCommandBuffer[4] & 255;
1832: h = prnCommandBuffer[5] & 255;
1833: n = (e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15);
1834: if (prnCommandLength < 6 + 2 * n) {
1835: prnCommandLength = 6 + 2 * n;
1836: return;
1837: }
1838: prn16DotBitImage (prnCommandBuffer, 6, n);
1839: break command;
1840: case 0x4a:
1841: if (prnCommandLength < 4) {
1842: prnCommandLength = 4;
1843: return;
1844: }
1845: e = prnCommandBuffer[2] & 255;
1846: f = prnCommandBuffer[3] & 255;
1847: n = e << 8 | f;
1848: if (prnCommandLength < 4 + 3 * n) {
1849: prnCommandLength = 4 + 3 * n;
1850: return;
1851: }
1852: prn24DotBitImage (prnCommandBuffer, 4, n);
1853: break command;
1854: case 0x4b:
1855: prnSetKanjiMode (true);
1856: break command;
1857: case 0x4c:
1858: if (prnCommandLength < 5) {
1859: prnCommandLength = 5;
1860: return;
1861: }
1862: e = prnCommandBuffer[2] & 255;
1863: f = prnCommandBuffer[3] & 255;
1864: g = prnCommandBuffer[4] & 255;
1865: prnSetLeftMargin ((e & 15) * 100 + (f & 15) * 10 + (g & 15));
1866: break command;
1867: case 0x4d:
1868: if (prnCommandLength < 4) {
1869: prnCommandLength = 4;
1870: return;
1871: }
1872: e = prnCommandBuffer[2] & 255;
1873: f = prnCommandBuffer[3] & 255;
1874: n = e << 8 | f;
1875: if (prnCommandLength < 4 + 6 * n) {
1876: prnCommandLength = 4 + 6 * n;
1877: return;
1878: }
1879: prn48DotBitImage (prnCommandBuffer, 4, n);
1880: break command;
1881: case 0x4e:
1882: if (prnCommandLength < 6) {
1883: prnCommandLength = 6;
1884: return;
1885: }
1886: e = prnCommandBuffer[2] & 255;
1887: f = prnCommandBuffer[3] & 255;
1888: g = prnCommandBuffer[4] & 255;
1889: h = prnCommandBuffer[5] & 255;
1890: prnRepeatCharacter ((e & 15) * 100 + (f & 15) * 10 + (g & 15), h);
1891: break command;
1892: case 0x50:
1893: prnSetKanjiMode (false);
1894: break command;
1895: case 0x51:
1896: prnSetSmallCharacterMode ();
1897: break command;
1898: case 0x52:
1899: prnSetPicaCharacterMode ();
1900: break command;
1901: case 0x55:
1902: prnSetHorizontalDoubleSizeMode (true);
1903: break command;
1904: case 0x56:
1905: if (prnCommandLength < 7) {
1906: prnCommandLength = 7;
1907: return;
1908: }
1909: e = prnCommandBuffer[2] & 255;
1910: f = prnCommandBuffer[3] & 255;
1911: g = prnCommandBuffer[4] & 255;
1912: h = prnCommandBuffer[5] & 255;
1913: i = prnCommandBuffer[6] & 255;
1914: prnRepeat8DotBitImage ((e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15), i);
1915: break command;
1916: case 0x57:
1917: if (prnCommandLength < 8) {
1918: prnCommandLength = 8;
1919: return;
1920: }
1921: e = prnCommandBuffer[2] & 255;
1922: f = prnCommandBuffer[3] & 255;
1923: g = prnCommandBuffer[4] & 255;
1924: h = prnCommandBuffer[5] & 255;
1925: i = prnCommandBuffer[6] & 255;
1926: j = prnCommandBuffer[7] & 255;
1927: prnRepeat16DotBitImage ((e & 15) * 1000 + (f & 15) * 100 + (g & 15) * 10 + (h & 15), i << 8 | j);
1928: break command;
1929: case 0x58:
1930: prnSetUnderlineMode (true);
1931: break command;
1932: case 0x59:
1933: prnSetUnderlineMode (false);
1934: break command;
1935: case 0x5c:
1936: if (prnCommandLength < 4) {
1937: prnCommandLength = 4;
1938: return;
1939: }
1940: e = prnCommandBuffer[2] & 255;
1941: f = prnCommandBuffer[3] & 255;
1942: prnHorizontalMove ((short) (f << 8 | e));
1943: break command;
1944: case 0x63:
1945: if (prnCommandLength < 3) {
1946: prnCommandLength = 3;
1947: return;
1948: }
1949: e = prnCommandBuffer[2] & 255;
1950: switch (e) {
1951: case 0x31:
1952: prnResetSettings ();
1953: break command;
1954: }
1955: break;
1956: case 0x6b:
1957: if (prnCommandLength < 3) {
1958: prnCommandLength = 3;
1959: return;
1960: }
1961: e = prnCommandBuffer[2] & 255;
1962: prnSetHalfWidthFont (e);
1963: break command;
1964: case 0x70:
1965: if (prnCommandLength < 3) {
1966: prnCommandLength = 3;
1967: return;
1968: }
1969: e = prnCommandBuffer[2] & 255;
1970: switch (e) {
1971: case 0x30:
1972: prnSenseOutOfPaper (false);
1973: break command;
1974: case 0x31:
1975: prnSenseOutOfPaper (true);
1976: break command;
1977: }
1978: break;
1979: case 0x71:
1980: if (prnCommandLength < 3) {
1981: prnCommandLength = 3;
1982: return;
1983: }
1984: e = prnCommandBuffer[2] & 255;
1985: prnSetCharacterStyle (e);
1986: break command;
1987: case 0x73:
1988: if (prnCommandLength < 3) {
1989: prnCommandLength = 3;
1990: return;
1991: }
1992: e = prnCommandBuffer[2] & 255;
1993: switch (e) {
1994: case 0x30:
1995: prnSetScriptMode (0);
1996: break command;
1997: case 0x31:
1998: prnSetScriptMode (1);
1999: break command;
2000: case 0x32:
2001: prnSetScriptMode (2);
2002: break command;
2003: }
2004: break;
2005: }
2006: break;
2007: case 0x1c:
2008: if (prnCommandLength < 2) {
2009: prnCommandLength = 2;
2010: return;
2011: }
2012: d = prnCommandBuffer[1] & 255;
2013: switch (d) {
2014: case 0x4a:
2015: prnSetVerticalWritingMode (true);
2016: break command;
2017: case 0x4b:
2018: prnSetVerticalWritingMode (false);
2019: break command;
2020: case 0x53:
2021: if (prnCommandLength < 4) {
2022: prnCommandLength = 4;
2023: return;
2024: }
2025: e = prnCommandBuffer[2] & 255;
2026: f = prnCommandBuffer[3] & 255;
2027: prnSetFullWidthLeftRightSpace (e, f);
2028: break command;
2029: case 0x54:
2030: if (prnCommandLength < 4) {
2031: prnCommandLength = 4;
2032: return;
2033: }
2034: e = prnCommandBuffer[2] & 255;
2035: f = prnCommandBuffer[3] & 255;
2036: prnSetHalfWidthLeftRightSpace (e, f);
2037: break command;
2038: case 0x6b:
2039: if (prnCommandLength < 3) {
2040: prnCommandLength = 3;
2041: return;
2042: }
2043: e = prnCommandBuffer[2] & 255;
2044: prnSetFullWidthFont (e);
2045: break command;
2046: case 0x70:
2047: prnSetKanjiHorizontalDoubleSizeMode (true);
2048: break command;
2049: case 0x71:
2050: prnSetKanjiHorizontalDoubleSizeMode (false);
2051: break command;
2052: }
2053: break;
2054: default:
2055: if (prnKanjiMode) {
2056: if (prnCommandLength < 2) {
2057: prnCommandLength = 2;
2058: return;
2059: }
2060: d = prnCommandBuffer[1] & 255;
2061: c = c << 8 | d;
2062: }
2063: if (c != 0) {
2064: prnPrintCharacter (c);
2065: }
2066: break command;
2067: }
2068:
2069: for (int k = 0; k < prnCommandLength; k++) {
2070: prnPrintCharacter (prnCommandBuffer[k] & 255);
2071: }
2072: }
2073:
2074: prnCommandLength = 1;
2075: prnCommandPointer = 0;
2076: }
2077:
2078:
2079:
2080: public static void prnFeedPaper () {
2081: if (prnCurrentPaper != null) {
2082: return;
2083: }
2084:
2085: prnCurrentPaper = prnNextPaper;
2086:
2087: prnDeadTopMm = Math.min (prnNextDeadTopMm, prnCurrentPaper.paperHeightMm - 1);
2088: prnDeadLeftMm = Math.min (prnNextDeadLeftMm, prnCurrentPaper.paperWidthMm - 1);
2089: prnDeadRightMm = Math.min (prnNextDeadRightMm, prnCurrentPaper.paperWidthMm - 1 - prnDeadLeftMm);
2090: prnDeadBottomMm = Math.min (prnNextDeadBottomMm, prnCurrentPaper.paperHeightMm - 1 - prnDeadTopMm);
2091:
2092: prnAliveTopY = (int) Math.floor ((double) prnDeadTopMm * (360.0 / 25.4) + 0.5);
2093: prnAliveLeftX = (int) Math.floor ((double) prnDeadLeftMm * (360.0 / 25.4) + 0.5);
2094: prnAliveRightX = (int) Math.floor ((double) (prnCurrentPaper.paperWidthMm - prnDeadRightMm) * (360.0 / 25.4) + 0.5);
2095: prnAliveBottomY = (int) Math.floor ((double) (prnCurrentPaper.paperHeightMm - prnDeadBottomMm) * (360.0 / 25.4) + 0.5);
2096:
2097: prnRotation = prnNextRotation;
2098: if (prnRotation == 0) {
2099: prnRotatedWidthDot = prnCurrentPaper.paperWidthDot;
2100: prnRotatedHeightDot = prnCurrentPaper.paperHeightDot;
2101:
2102:
2103:
2104: prnM11 = 1;
2105: prnM12 = 0;
2106: prnM13 = 0;
2107: prnM21 = 0;
2108: prnM22 = 1;
2109: prnM23 = 0;
2110: } else if (prnRotation == 1) {
2111: prnRotatedWidthDot = prnCurrentPaper.paperHeightDot;
2112: prnRotatedHeightDot = prnCurrentPaper.paperWidthDot;
2113:
2114:
2115:
2116: prnM11 = 0;
2117: prnM12 = -1;
2118: prnM13 = prnRotatedWidthDot;
2119: prnM21 = 1;
2120: prnM22 = 0;
2121: prnM23 = 0;
2122: } else if (prnRotation == 2) {
2123: prnRotatedWidthDot = prnCurrentPaper.paperWidthDot;
2124: prnRotatedHeightDot = prnCurrentPaper.paperHeightDot;
2125:
2126:
2127:
2128: prnM11 = -1;
2129: prnM12 = 0;
2130: prnM13 = prnRotatedWidthDot;
2131: prnM21 = 0;
2132: prnM22 = -1;
2133: prnM23 = prnRotatedHeightDot;
2134: } else {
2135: prnRotatedWidthDot = prnCurrentPaper.paperHeightDot;
2136: prnRotatedHeightDot = prnCurrentPaper.paperWidthDot;
2137:
2138:
2139:
2140: prnM11 = 0;
2141: prnM12 = 1;
2142: prnM13 = 0;
2143: prnM21 = -1;
2144: prnM22 = 0;
2145: prnM23 = prnRotatedHeightDot;
2146: }
2147: prnIncrementX = prnM11 + prnRotatedWidthDot * prnM21;
2148: prnIncrementY = prnM12 + prnRotatedWidthDot * prnM22;
2149:
2150: prnDarkMode = prnNextDarkMode;
2151:
2152: prnImage = new BufferedImage (prnRotatedWidthDot,
2153: prnRotatedHeightDot,
2154: BufferedImage.TYPE_BYTE_INDEXED, prnDarkMode ? prnDarkImageColorModel : prnImageColorModel);
2155: prnBitmap = ((DataBufferByte) prnImage.getRaster ().getDataBuffer ()).getData ();
2156: if (prnCanvas != null) {
2157: prnCanvas.setImage (prnImage);
2158: }
2159:
2160: prnErasePaper ();
2161: }
2162:
2163:
2164:
2165:
2166: public static void prnErasePaper () {
2167: if (prnCurrentPaper == null) {
2168: prnFeedPaper ();
2169: } else {
2170:
2171: prnPageStart = 0;
2172: prnPageLength = ((prnAliveBottomY - prnAliveTopY + (360 - 1)) / 360) * 360;
2173:
2174: prnContentTopY = prnPageStart;
2175: prnContentBottomY = prnPageStart + prnPageLength - prnMarginBottomHeight;
2176:
2177: prnHeadX = prnMarginLeftX;
2178: prnHeadY = prnContentTopY;
2179: prnHeadLine = 0;
2180:
2181: Arrays.fill (prnBitmap, 0, prnRotatedWidthDot * prnRotatedHeightDot, (byte) 7);
2182:
2183: prnPrinted = false;
2184:
2185: if (prnCanvas != null) {
2186: prnCanvas.repaint ();
2187: }
2188: }
2189: }
2190:
2191:
2192:
2193: public static void prnEjectPaper () {
2194: if (prnCurrentPaper == null) {
2195: return;
2196: }
2197: if (prnPrinted) {
2198: prnPrinted = false;
2199: prnSavePaper ();
2200: }
2201: prnCurrentPaper = null;
2202: prnHeadX = -1;
2203: prnHeadY = -1;
2204: prnHeadLine = -1;
2205: if (prnCanvas != null) {
2206: prnCanvas.setImage (null);
2207: }
2208: }
2209:
2210:
2211:
2212:
2213:
2214:
2215:
2216:
2217:
2218: public static void prnSavePaper () {
2219:
2220: while (new File (prnSavePath + File.separator + prnSaveName).isFile ()) {
2221: int j = prnSaveName.lastIndexOf ('.');
2222: if (j < 0) {
2223: j = prnSaveName.length ();
2224: }
2225: int i = j;
2226: int n = 2;
2227: if (0 < j && Character.isDigit (prnSaveName.charAt (j - 1))) {
2228:
2229: i--;
2230: while (j - 8 < i &&
2231: 0 < i && Character.isDigit (prnSaveName.charAt (i - 1))) {
2232: i--;
2233: }
2234: n = Integer.parseInt (prnSaveName.substring (i, j));
2235: n = (n + 1) % 100000000;
2236: }
2237: prnSaveName = prnSaveName.substring (0, i) + n + prnSaveName.substring (j);
2238: }
2239:
2240: File file = new File (prnSavePath + File.separator + prnSaveName).getAbsoluteFile ();
2241: File parent = file.getParentFile ();
2242: prnSavePath = parent.getAbsolutePath ();
2243: prnSaveName = file.getName ();
2244: parent.mkdirs ();
2245:
2246: if (prnAutosaveOn) {
2247: if (!prnSave ()) {
2248: prnSetAutosaveOn (false);
2249: }
2250: }
2251: if (!prnAutosaveOn) {
2252: if (prnSaveDialog == null) {
2253: prnMakeSaveDialog ();
2254: }
2255: prnSaveFileChooser.setCurrentDirectory (parent);
2256: prnSaveFileChooser.rescanCurrentDirectory ();
2257: prnSaveFileChooser.setSelectedFile (file);
2258:
2259:
2260: prnSaveDialog.setVisible (true);
2261: }
2262: }
2263:
2264: private static final byte[] PRN_DOUBLE_4BIT = {
2265: 0b00_00_00_00,
2266: 0b00_00_00_11,
2267: 0b00_00_11_00,
2268: 0b00_00_11_11,
2269: 0b00_11_00_00,
2270: 0b00_11_00_11,
2271: 0b00_11_11_00,
2272: 0b00_11_11_11,
2273: (byte) 0b11_00_00_00,
2274: (byte) 0b11_00_00_11,
2275: (byte) 0b11_00_11_00,
2276: (byte) 0b11_00_11_11,
2277: (byte) 0b11_11_00_00,
2278: (byte) 0b11_11_00_11,
2279: (byte) 0b11_11_11_00,
2280: (byte) 0b11_11_11_11,
2281: };
2282:
2283:
2284:
2285: public static void prnSetSingleColor (int color) {
2286: prnSingleColor = color;
2287: if (!prnColorMode) {
2288: prnCurrentColor = color;
2289: }
2290: }
2291:
2292:
2293:
2294: public static int prnGetCharacterWidth () {
2295: return (prnKanjiMode ?
2296: (prnHalfWidthLeftSpace + 24 + prnHalfWidthRightSpace) *
2297: (prnHorizontalDoubleSizeMode || prnKanjiHorizontalDoubleSizeMode ? 2 : 1) :
2298: (prnCharacterType == PRN_PICA ? 36 :
2299: prnCharacterType == PRN_ELITE ? 30 :
2300: prnCharacterType == PRN_SMALL ? 21 : 0) *
2301: (prnHorizontalDoubleSizeMode ? 2 : 1));
2302: }
2303:
2304:
2305:
2306:
2307: public static void prnPrintCharacter (int c) {
2308: c = (char) c;
2309: if (prnCurrentPaper == null) {
2310: prnFeedPaper ();
2311: }
2312:
2313: FontPage page = null;
2314: int y0 = 0;
2315: int col = 0;
2316: int row = 0;
2317: int w;
2318: int h;
2319: int o;
2320: int oh;
2321: byte[] b;
2322: gaiji:
2323: {
2324: if (c <= 0x00ff) {
2325: col = c & 15;
2326: row = c >> 4;
2327: if (prnKanjiMode) {
2328: page = prnHalfWidthFont == 0 ? fntPagePan24x48R : fntPagePan24x48S;
2329: } else {
2330: if (prnHiraganaMode) {
2331: row += 16;
2332: }
2333: if (prnCharacterType == PRN_PICA) {
2334: page = prnHalfWidthFont == 0 ? fntPagePic36x46R : fntPagePic36x46S;
2335: } else if (prnCharacterType == PRN_ELITE) {
2336: page = prnHalfWidthFont == 0 ? fntPageEli30x46R : fntPageEli30x46S;
2337: } else if (prnCharacterType == PRN_SMALL) {
2338: page = prnHalfWidthFont == 0 ? fntPageSma18x46R : fntPageSma18x46S;
2339: } else {
2340: page = prnHalfWidthFont == 0 ? fntPageScr28x32R : fntPageScr28x32S;
2341: if (prnScriptMode == 2) {
2342: y0 = 14;
2343: }
2344: }
2345: }
2346: } else {
2347: page = prnFullWidthFont == 0 ? fntPageZen48x48M : fntPageZen48x48G;
2348: row = c >> 8;
2349: col = c & 255;
2350: if (((0x81 <= row && row <= 0x9f) ||
2351: (0xe0 <= row && row <= 0xef)) &&
2352: ((0x40 <= col && col <= 0x7e) ||
2353: (0x80 <= col && col <= 0xfc))) {
2354:
2355:
2356:
2357:
2358:
2359: if (0xe0 <= row) {
2360: row -= 0xe0 - 0xa0;
2361: }
2362: row -= 0x81;
2363: if (0x80 <= col) {
2364: col -= 0x80 - 0x7f;
2365: }
2366: col -= 0x40;
2367: row *= 2;
2368: if (94 <= col) {
2369: row += 1;
2370: col -= 94;
2371: }
2372: row += 0x21;
2373: col += 0x21;
2374: }
2375: if ((row == 0x76 && (0x21 <= col && col <= 0x7e)) ||
2376: (row == 0x77 && (0x21 <= col && col <= 0x26))) {
2377: w = 48;
2378: h = 48;
2379: o = 6;
2380: oh = o * h;
2381: b = new byte[oh];
2382: System.arraycopy (prnGetGaijiData (), oh * ((col - 0x21) + 94 * (row - 0x76)), b, 0, oh);
2383: break gaiji;
2384: }
2385: if (0x21 <= col && col <= 0x7e) {
2386: col -= 0x21;
2387: if (0x21 <= row && row <= 0x28) {
2388: row -= 0x21;
2389: } else if (0x30 <= row && row <= 0x74) {
2390:
2391: row -= 0x21;
2392: } else {
2393: row = 0;
2394: col = 0;
2395: }
2396: } else {
2397: row = 0;
2398: col = 0;
2399: }
2400: }
2401: if (!page.fnpReady) {
2402: page.fnpCreateImage ((c <= 0x00ff ? prnHalfWidthFont : prnFullWidthFont) == 0 ? fntGetMinchoFamily () : fntGetGothicFamily ());
2403: }
2404: w = page.fnpCharacterWidth;
2405: h = page.fnpCharacterHeight;
2406: o = page.fnpCharacterHorizontalBytes;
2407: oh = o * h;
2408: b = new byte[o * y0 + oh];
2409: System.arraycopy (page.fnpBinaryArray, oh * (col + page.fnpImageCols * row), b, o * y0, oh);
2410: }
2411: h += y0;
2412: oh = o * h;
2413:
2414:
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: if (prnVerticalWritingMode &&
2459: page != null && page.fnpImageCols == 94 &&
2460: !((row == 0x21 - 0x21 && ((0x26 - 0x21 <= col && col <= 0x28 - 0x21) ||
2461: (col == 0x5d - 0x21) ||
2462: (0x62 - 0x21 <= col && col <= 0x66 - 0x21))) ||
2463: (row == 0x22 - 0x21 && (0x2a - 0x21 <= col && col <= 0x2d - 0x21)) ||
2464: (row == 0x28 - 0x21 && (0x21 - 0x21 <= col && col <= 0x40 - 0x21)))) {
2465: boolean rotate;
2466: if (row == 0x21 - 0x21 && (0x22 - 0x21 <= col && col <= 0x23 - 0x21)) {
2467:
2468: byte[] bb = new byte[6 * 48];
2469:
2470:
2471: for (int yy = 0; yy < 48 / 3; yy++) {
2472: int y = yy + 48 * 2 / 3;
2473: for (int xx = 48 * 2 / 3; xx < 48; xx++) {
2474: int x = xx - 48 * 2 / 3;
2475: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2476: }
2477: }
2478: b = bb;
2479: rotate = true;
2480: } else if (row == 0x21 - 0x21 && (col == 0x3c - 0x21 ||
2481: col == 0x41 - 0x21)) {
2482:
2483: byte[] bb = new byte[6 * 48];
2484:
2485:
2486: for (int yy = 0; yy < 48; yy++) {
2487: int y = 48 - 1 - yy;
2488: for (int xx = 0; xx < 48; xx++) {
2489: int x = xx;
2490: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2491: }
2492: }
2493: b = bb;
2494: rotate = false;
2495: } else if ((row == 0x24 - 0x21 && (col == 0x21 - 0x21 ||
2496: col == 0x23 - 0x21 ||
2497: col == 0x25 - 0x21 ||
2498: col == 0x27 - 0x21 ||
2499: col == 0x29 - 0x21 ||
2500: col == 0x43 - 0x21 ||
2501: col == 0x63 - 0x21 ||
2502: col == 0x65 - 0x21 ||
2503: col == 0x67 - 0x21 ||
2504: col == 0x6e - 0x21)) ||
2505: (row == 0x25 - 0x21 && (col == 0x21 - 0x21 ||
2506: col == 0x23 - 0x21 ||
2507: col == 0x25 - 0x21 ||
2508: col == 0x27 - 0x21 ||
2509: col == 0x29 - 0x21 ||
2510: col == 0x43 - 0x21 ||
2511: col == 0x63 - 0x21 ||
2512: col == 0x65 - 0x21 ||
2513: col == 0x67 - 0x21 ||
2514: col == 0x6e - 0x21 ||
2515: col == 0x75 - 0x21 ||
2516: col == 0x76 - 0x21))) {
2517:
2518: byte[] bb = new byte[6 * 48];
2519:
2520:
2521: for (int yy = 0; yy < 48 * 7 / 8; yy++) {
2522: int y = yy + 48 / 8;
2523: for (int xx = 48 / 8; xx < 48; xx++) {
2524: int x = xx - 48 / 8;
2525: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2526: }
2527: }
2528: b = bb;
2529: rotate = true;
2530: } else if (row == 0x21 - 0x21 && ((0x31 - 0x21 <= col && col <= 0x32 - 0x21) ||
2531: (0x3d - 0x21 <= col && col <= 0x3e - 0x21) ||
2532: (0x42 - 0x21 <= col && col <= 0x45 - 0x21) ||
2533: (0x4a - 0x21 <= col && col <= 0x5b - 0x21) ||
2534: col == 0x61 - 0x21)) {
2535: rotate = false;
2536: } else {
2537: rotate = true;
2538: }
2539: if (rotate) {
2540:
2541:
2542:
2543: byte[] bb = new byte[6 * 48];
2544:
2545:
2546: for (int yy = 0; yy < 48; yy++) {
2547: int x = 48 - 1 - yy;
2548: for (int xx = 0; xx < 48; xx++) {
2549: int y = xx;
2550: bb[6 * yy + (xx >> 3)] |= (byte) ((b[6 * y + (x >> 3)] >> (~x & 7) & 1) << (~xx & 7));
2551: }
2552: }
2553: b = bb;
2554: }
2555: }
2556: if (false) {
2557:
2558:
2559:
2560: if (h < 48) {
2561: int hh = 48;
2562: int ohh = o * hh;
2563: byte[] bb = new byte[ohh];
2564: System.arraycopy (b, 0, bb, 0, oh);
2565:
2566: h = hh;
2567: oh = ohh;
2568: b = bb;
2569: }
2570: }
2571:
2572: {
2573: int lw = 0;
2574: int rw = 0;
2575: if (prnKanjiMode) {
2576: if (w == 48) {
2577: lw = prnFullWidthLeftSpace;
2578: rw = prnFullWidthRightSpace;
2579: } else {
2580: lw = prnHalfWidthLeftSpace;
2581: rw = prnHalfWidthRightSpace;
2582: }
2583: } else if (prnCharacterType == PRN_SMALL) {
2584: rw = 3;
2585: }
2586: if (lw != 0 || rw != 0) {
2587: int ww = lw + w + rw;
2588: int oo = (ww + 7) >> 3;
2589: int ooh = oo * h;
2590: byte[] bb = new byte[ooh];
2591: Arrays.fill (bb, (byte) 0);
2592:
2593: int lq = lw >> 3;
2594: int lr = lw & 7;
2595: if (lr == 0) {
2596: for (int a = 0, aa = lq; a < oh; a += o, aa += oo) {
2597: for (int i = o - 1; 0 <= i; i--) {
2598: bb[aa + i] = b[a + i];
2599: }
2600: }
2601: } else {
2602: for (int a = 0, aa = lq; a < oh; a += o, aa += oo) {
2603: bb[aa + o] = (byte) (b[a + o - 1] << (8 - lr));
2604: for (int i = o - 1; 0 < i; i--) {
2605: bb[aa + i] = (byte) ((b[a + i - 1] << (8 - lr)) | (b[a + i] & 255) >> lr);
2606: }
2607: bb[aa] = (byte) ((b[a] & 255) >> lr);
2608: }
2609: }
2610: w = ww;
2611: o = oo;
2612: oh = ooh;
2613: b = bb;
2614: }
2615: }
2616:
2617: if (prnStrongMode) {
2618:
2619:
2620: for (int a = 0; a < oh; a += o) {
2621: for (int i = o - 1; 0 < i; i--) {
2622: b[a + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2623: }
2624: b[a] |= (byte) ((b[a] & 255) >> 1);
2625: }
2626: }
2627:
2628: if (prnCharacterStyle != 0) {
2629:
2630:
2631:
2632:
2633:
2634:
2635:
2636:
2637: byte[] bb = new byte[oh];
2638: Arrays.fill (bb, (byte) 0);
2639: if (prnVerticalWritingMode) {
2640:
2641: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2642: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2643: for (int i = 1; i < o; i++) {
2644: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2645: }
2646: }
2647: } else {
2648:
2649: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2650: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2651: for (int i = 1; i < o; i++) {
2652: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2653: }
2654: }
2655: }
2656: if (prnCharacterStyle == PRN_SHADOW_STYLE ||
2657: prnCharacterStyle == PRN_OPEN_SHADOW_STYLE) {
2658: if (prnVerticalWritingMode) {
2659:
2660: for (int a = o * 2, aa = 0; a < oh; a += o, aa += o) {
2661: bb[aa] |= (byte) ((b[a] & 255) >> 2);
2662: for (int i = 1; i < o; i++) {
2663: bb[aa + i] |= (byte) (b[a + i - 1] << 6 | (b[a + i] & 255) >> 2);
2664: }
2665: }
2666: } else {
2667:
2668: for (int a = 0, aa = o * 2; aa < oh; a += o, aa += o) {
2669: bb[aa] |= (byte) ((b[a] & 255) >> 2);
2670: for (int i = 1; i < o; i++) {
2671: bb[aa + i] |= (byte) (b[a + i - 1] << 6 | (b[a + i] & 255) >> 2);
2672: }
2673: }
2674: }
2675: }
2676: if (prnCharacterStyle == PRN_OPEN_STYLE ||
2677: prnCharacterStyle == PRN_OPEN_SHADOW_STYLE) {
2678:
2679: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2680: for (int i = 0; i < o - 1; i++) {
2681: bb[aa + i] |= (byte) (b[a + i] << 1 | (b[a + i + 1] & 255) >> 7);
2682: }
2683: bb[aa + o - 1] |= (byte) (b[a + o - 1] << 1);
2684: }
2685:
2686: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2687: for (int i = 0; i < o; i++) {
2688: bb[aa + i] |= b[a + i];
2689: }
2690: }
2691: if (prnVerticalWritingMode) {
2692:
2693: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2694: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2695: for (int i = 1; i < o; i++) {
2696: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2697: }
2698: }
2699: } else {
2700:
2701: for (int a = o, aa = 0; a < oh; a += o, aa += o) {
2702: bb[aa] |= (byte) ((b[a] & 255) >> 1);
2703: for (int i = 1; i < o; i++) {
2704: bb[aa + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2705: }
2706: }
2707: }
2708:
2709: for (int a = 0; a < oh; a += o) {
2710: for (int i = 0; i < o - 1; i++) {
2711: bb[a + i] |= (byte) (b[a + i] << 1 | (b[a + i + 1] & 255) >> 7);
2712: }
2713: bb[a + o - 1] |= (byte) (b[a + o - 1] << 1);
2714: }
2715:
2716: for (int a = 0; a < oh; a += o) {
2717: bb[a] |= (byte) ((b[a] & 255) >> 1);
2718: for (int i = 1; i < o; i++) {
2719: bb[a + i] |= (byte) (b[a + i - 1] << 7 | (b[a + i] & 255) >> 1);
2720: }
2721: }
2722:
2723: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2724: for (int i = 0; i < o - 1; i++) {
2725: bb[aa + i] |= (byte) (b[a + i] << 1 | (b[a + i + 1] & 255) >> 7);
2726: }
2727: bb[aa + o - 1] |= (byte) (b[a + o - 1] << 1);
2728: }
2729:
2730: for (int a = 0, aa = o; aa < oh; a += o, aa += o) {
2731: for (int i = 0; i < o; i++) {
2732: bb[aa + i] |= b[a + i];
2733: }
2734: }
2735: }
2736:
2737: for (int i = 0; i < oh; i++) {
2738: bb[i] &= (byte) ~b[i];
2739: }
2740: b = bb;
2741: }
2742:
2743:
2744: if (prnUnderlineMode) {
2745: if (prnVerticalWritingMode) {
2746: int a = 0;
2747: for (int i = 0; i < o - 1; i++) {
2748: b[a + i] = -1;
2749: }
2750: b[a + o - 1] |= (byte) (-256 >> (((w - 1) & 7) + 1));
2751: } else {
2752: int a = o * (h - 1);
2753: for (int i = 0; i < o - 1; i++) {
2754: b[a + i] = -1;
2755: }
2756: b[a + o - 1] |= (byte) (-256 >> (((w - 1) & 7) + 1));
2757: }
2758: }
2759:
2760: if (prnHorizontalDoubleSizeMode ||
2761: (prnKanjiMode && prnKanjiHorizontalDoubleSizeMode)) {
2762: int ww = w * 2;
2763: int oo = (ww + 7) >> 3;
2764: int ooh = oo * h;
2765: byte[] bb = new byte[ooh];
2766: for (int a = 0, aa = 0; a < oh; a += o, aa += oo) {
2767: for (int i = 0, ii = 0; i < o; i++, ii += 2) {
2768: int d = b[a + i] & 255;
2769: bb[aa + ii] = PRN_DOUBLE_4BIT[d >> 4];
2770: if (ii + 1 < oo) {
2771: bb[aa + ii + 1] = PRN_DOUBLE_4BIT[d & 15];
2772: }
2773: }
2774: }
2775: w = ww;
2776: o = oo;
2777: oh = ooh;
2778: b = bb;
2779: }
2780:
2781: if (prnVerticalDoubleSizeMode) {
2782: int hh = h * 2;
2783: int ohh = o * hh;
2784: byte[] bb = new byte[ohh];
2785: for (int a = 0, aa = 0; a < oh; a += o, aa += o * 2) {
2786: for (int i = 0; i < o; i++) {
2787: bb[aa + o + i] = bb[aa + i] = b[a + i];
2788: }
2789: }
2790: h = hh;
2791: oh = ohh;
2792: b = bb;
2793: }
2794:
2795: if (prnMarginLeftX < prnHeadX &&
2796: prnMarginRightX < prnHeadX + w) {
2797:
2798: prnHeadX = prnMarginLeftX;
2799: prnHeadY += prnLineHeight;
2800: prnHeadLine++;
2801: }
2802:
2803: if (prnContentTopY < prnHeadY &&
2804: prnContentBottomY < prnHeadY + h) {
2805:
2806: prnPrintFormFeed ();
2807: }
2808:
2809: int bi = prnCheckRect (w, h);
2810: if (0 <= bi) {
2811: int ix = prnIncrementX;
2812: int iy = prnIncrementY;
2813: for (int y = 0; y < h; y++) {
2814: int i = bi;
2815: for (int x = 0; x < w; x++) {
2816: if ((b[(x >> 3) + o * y] >> (~x & 7) & 1) != 0) {
2817: prnBitmap[i] &= (byte) prnCurrentColor;
2818: }
2819: i += ix;
2820: }
2821: bi += iy;
2822: }
2823: } else {
2824: for (int y = 0; y < h; y++) {
2825: for (int x = 0; x < w; x++) {
2826: if ((b[(x >> 3) + o * y] >> (~x & 7) & 1) != 0) {
2827: prnPaintDot (x, y);
2828: }
2829: }
2830: }
2831: }
2832: prnHeadX += w;
2833:
2834: prnPrinted = true;
2835:
2836: if (prnCanvas != null) {
2837: prnCanvas.repaint ();
2838: }
2839: }
2840:
2841:
2842:
2843:
2844:
2845:
2846:
2847: public static void prnPrintBackSpace () {
2848: if (prnCurrentPaper == null) {
2849: prnFeedPaper ();
2850: }
2851: prnHeadX = Math.max (prnMarginLeftX, prnHeadX - prnGetCharacterWidth ());
2852: }
2853:
2854:
2855:
2856:
2857:
2858: public static void prnPrintHorizontalTab () {
2859: if (prnCurrentPaper == null) {
2860: prnFeedPaper ();
2861: }
2862: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
2863: int x = prnHorizontalTabAnchor[k];
2864: if (x == 0) {
2865: break;
2866: }
2867: if (prnHeadX < x) {
2868: prnHeadX = Math.min (x, prnMarginRightX - 1);
2869: break;
2870: }
2871: }
2872: }
2873:
2874:
2875:
2876:
2877:
2878:
2879: public static void prnSetStartColumn (int n) {
2880: if (prnCurrentPaper == null) {
2881: prnFeedPaper ();
2882: }
2883: if (0 <= n && n <= 999) {
2884: int startX = prnGetCharacterWidth () * n;
2885: if (prnMarginLeftX + startX < prnMarginRightX) {
2886: prnHeadX = prnMarginLeftX + startX;
2887: }
2888: }
2889: }
2890:
2891:
2892:
2893:
2894:
2895:
2896: public static void prnPrintLineFeed (int n) {
2897: if (prnCurrentPaper == null) {
2898: prnFeedPaper ();
2899: }
2900: if (n < 0) {
2901: n = 0;
2902: }
2903: if (prnVerticalDoubleSizeMode) {
2904: n *= 2;
2905: }
2906:
2907: prnHeadY += prnLineHeight * n;
2908: prnHeadLine += n;
2909:
2910: if (prnContentBottomY <= prnHeadY) {
2911:
2912: prnPrintFormFeed ();
2913: }
2914:
2915: if (prnColorMode) {
2916: prnColorMode = false;
2917: prnCurrentColor = prnSingleColor;
2918: }
2919: }
2920:
2921:
2922:
2923:
2924:
2925:
2926: public static void prnPrintVerticalTab (int n) {
2927: if (prnCurrentPaper == null) {
2928: prnFeedPaper ();
2929: }
2930: for (int k = prnHeadLine; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
2931: if (prnVerticalTabAnchor[k] == n) {
2932: int d = k - prnHeadLine;
2933:
2934: prnHeadX = prnMarginLeftX;
2935: prnHeadY += prnLineHeight * d;
2936: prnHeadLine += d;
2937:
2938: if (prnContentBottomY <= prnHeadY) {
2939:
2940: prnPrintFormFeed ();
2941: }
2942: return;
2943: }
2944: }
2945: }
2946:
2947:
2948:
2949:
2950: public static void prnPrintFormFeed () {
2951:
2952: prnPageStart += prnPageLength;
2953:
2954: prnContentTopY = prnPageStart;
2955: prnContentBottomY = Math.min (prnPageStart + prnPageLength - prnMarginBottomHeight,
2956: prnAliveBottomY - prnAliveTopY);
2957:
2958: prnHeadX = prnMarginLeftX;
2959: prnHeadY = prnContentTopY;
2960: prnHeadLine = 0;
2961:
2962: if (prnAliveBottomY <= prnAliveTopY + prnHeadY) {
2963: prnEjectPaper ();
2964: prnFeedPaper ();
2965: }
2966: }
2967:
2968:
2969:
2970:
2971: public static void prnPrintCarriageReturn () {
2972: if (prnCurrentPaper == null) {
2973: prnFeedPaper ();
2974: }
2975:
2976: prnHeadX = prnMarginLeftX;
2977:
2978: if (prnColorMode) {
2979: prnCurrentColor = prnCurrentColor == 6 ? 5 : prnCurrentColor == 5 ? 3 : 6;
2980: }
2981: }
2982:
2983:
2984:
2985:
2986:
2987: public static void prnSetHorizontalDoubleSizeMode (boolean b) {
2988: prnHorizontalDoubleSizeMode = b;
2989: }
2990:
2991:
2992:
2993:
2994: public static void prnSelect (boolean b) {
2995:
2996: }
2997:
2998:
2999:
3000:
3001:
3002:
3003:
3004:
3005:
3006: public static void prnSetVerticalTabAnchor (byte[] a, int o, int n) {
3007: if (prnCurrentPaper == null) {
3008: prnFeedPaper ();
3009: }
3010: prnSetPageStartPosition ();
3011: int pp = '0';
3012: int k = 0;
3013: for (; k < PRN_VERTICAL_ANCHOR_LIMIT && k < n; k++) {
3014: int p = a[o + k];
3015: if (p == '0') {
3016: prnVerticalTabAnchor[k] = 0;
3017: } else if ('1' <= p && p <= '<') {
3018: if (p <= pp) {
3019: break;
3020: }
3021: prnVerticalTabAnchor[k] = p - '0';
3022: pp = p;
3023: } else {
3024: break;
3025: }
3026: }
3027: for (; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
3028: prnVerticalTabAnchor[k] = 0;
3029: }
3030: }
3031:
3032:
3033:
3034: public static void prnCancel () {
3035:
3036: }
3037:
3038:
3039:
3040:
3041: public static void prnSetVerticalDoubleSizeMode (boolean b) {
3042: prnVerticalDoubleSizeMode = b;
3043: }
3044:
3045:
3046:
3047:
3048: public static void prnSetHorizontalStartPosition (int n) {
3049: if (prnCurrentPaper == null) {
3050: prnFeedPaper ();
3051: }
3052: if (0 <= n && n <= 9999) {
3053: int startX = 2 * n;
3054: if (prnMarginLeftX + startX < prnMarginRightX) {
3055: prnHeadX = prnMarginLeftX + startX;
3056: }
3057: }
3058: }
3059:
3060:
3061:
3062: public static void prnSetColorMode () {
3063: prnColorMode = true;
3064: prnCurrentColor = 6;
3065: }
3066:
3067:
3068:
3069:
3070: public static void prnSetStrongMode (boolean b) {
3071: prnStrongMode = b;
3072: }
3073:
3074:
3075:
3076:
3077: public static void prnSetHiraganaMode (boolean b) {
3078: prnHiraganaMode = b;
3079: }
3080:
3081:
3082:
3083:
3084:
3085:
3086: public static void prnSetLineHeight (int n) {
3087: if (0 <= n && n <= 127) {
3088: if (n == 0) {
3089: prnLineHeight = prnDefaultLineHeight;
3090: } else {
3091: prnLineHeight = 3 * n;
3092: }
3093: }
3094: }
3095:
3096:
3097:
3098:
3099:
3100:
3101:
3102:
3103:
3104:
3105:
3106:
3107:
3108:
3109: public static void prn8DotBitImage (byte[] a, int o, int n) {
3110: if (prnCurrentPaper == null) {
3111: prnFeedPaper ();
3112: }
3113:
3114: }
3115:
3116:
3117:
3118:
3119:
3120:
3121:
3122:
3123:
3124: public static void prnSetHorizontalTabAnchor (byte[] a, int o, int n) {
3125: if (prnCurrentPaper == null) {
3126: prnFeedPaper ();
3127: }
3128: int characterWidth = prnGetCharacterWidth ();
3129: n += o;
3130: int k = 0;
3131: while (k < PRN_HORIZONTAL_ANCHOR_LIMIT &&
3132: o < n && '0' <= a[o] && a[o] <= '9') {
3133: int p = a[o] - '0';
3134: o++;
3135: while (o < n && '0' <= a[o] && a[o] <= '9') {
3136: p = p * 10 + (a[o] - '0');
3137: o++;
3138: }
3139: int x = prnMarginLeftX + characterWidth * p;
3140: if ((k == 0 ? prnMarginLeftX :
3141: prnHorizontalTabAnchor[k - 1]) < x) {
3142: prnHorizontalTabAnchor[k] = x;
3143: k++;
3144: }
3145: if (o < n && a[o] == ',') {
3146: o++;
3147: } else {
3148: break;
3149: }
3150: }
3151: for (; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3152: prnHorizontalTabAnchor[k] = 0;
3153: }
3154: }
3155:
3156:
3157:
3158:
3159:
3160:
3161: public static void prnClearHorizontalTabAnchor (byte[] a, int o, int n) {
3162: if (prnCurrentPaper == null) {
3163: prnFeedPaper ();
3164: }
3165: int characterWidth = prnGetCharacterWidth ();
3166: n += o;
3167: while (o < n && '0' <= a[o] && a[o] <= '9') {
3168: int p = a[o] - '0';
3169: o++;
3170: while (o < n && '0' <= a[o] && a[o] <= '9') {
3171: p = p * 10 + (a[o] - '0');
3172: o++;
3173: }
3174: int x = prnMarginLeftX + characterWidth * p;
3175: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3176: int t = prnHorizontalTabAnchor[k];
3177: if (t == 0 ||
3178: x < t) {
3179: break;
3180: }
3181: if (t == x) {
3182: int j = k;
3183: for (; j < PRN_HORIZONTAL_ANCHOR_LIMIT - 1; j++) {
3184: prnHorizontalTabAnchor[j] = prnHorizontalTabAnchor[j + 1];
3185: }
3186: prnHorizontalTabAnchor[j] = 0;
3187: break;
3188: }
3189: }
3190: if (o < n && a[o] == ',') {
3191: o++;
3192: } else {
3193: break;
3194: }
3195: }
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: public static void prn16DotExtendedCharacterDefinition (byte[] a, int o, int n) {
3226: byte[] gaijiData = prnGetGaijiData ();
3227: int n1 = a[o] & 255;
3228: int n2 = a[o + 1] & 255;
3229: if (!((n1 == 0x76 && (0x21 <= n2 && n2 <= 0x7e)) ||
3230: (n1 == 0x77 && (0x21 <= n2 && n2 <= 0x26)))) {
3231: return;
3232: }
3233: int i = 6 * 48 * ((n2 - 0x21) + 94 * (n1 - 0x76));
3234: int j = o + 2;
3235: for (int y = 0; y < 16; y++) {
3236: int t = 0;
3237: for (int x = 0; x < 8; x++) {
3238: t = t << 3 | (a[j + 2 * x + (y >> 3)] >> (~y & 7) & 1) * 7;
3239: }
3240: gaijiData[i ] = gaijiData[i + 6] = gaijiData[i + 12] = (byte) (t >> 16);
3241: gaijiData[i + 1] = gaijiData[i + 7] = gaijiData[i + 13] = (byte) (t >> 8);
3242: gaijiData[i + 2] = gaijiData[i + 8] = gaijiData[i + 14] = (byte) t;
3243: t = 0;
3244: for (int x = 8; x < 16; x++) {
3245: t = t << 3 | (a[j + 2 * x + (y >> 3)] >> (~y & 7) & 1) * 7;
3246: }
3247: gaijiData[i + 3] = gaijiData[i + 9] = gaijiData[i + 15] = (byte) (t >> 16);
3248: gaijiData[i + 4] = gaijiData[i + 10] = gaijiData[i + 16] = (byte) (t >> 8);
3249: gaijiData[i + 5] = gaijiData[i + 11] = gaijiData[i + 17] = (byte) t;
3250: i += 18;
3251: }
3252: }
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: public static void prn24DotExtendedCharacterDefinition (byte[] a, int o, int n) {
3292: byte[] gaijiData = prnGetGaijiData ();
3293: int n1 = a[o] & 255;
3294: int n2 = a[o + 1] & 255;
3295: if (!((n1 == 0x76 && (0x21 <= n2 && n2 <= 0x7e)) ||
3296: (n1 == 0x77 && (0x21 <= n2 && n2 <= 0x26)))) {
3297: return;
3298: }
3299: int i = 6 * 48 * ((n2 - 0x21) + 94 * (n1 - 0x76));
3300: int j = o + 2;
3301: for (int y = 0; y < 24; y++) {
3302: int t = 0;
3303: for (int x = 0; x < 16; x++) {
3304: t = t << 2 | (a[j + 3 * x + (y >> 3)] >> (~y & 7) & 1) * 3;
3305: }
3306: gaijiData[i ] = gaijiData[i + 6] = (byte) (t >> 24);
3307: gaijiData[i + 1] = gaijiData[i + 7] = (byte) (t >> 16);
3308: gaijiData[i + 2] = gaijiData[i + 8] = (byte) (t >> 8);
3309: gaijiData[i + 3] = gaijiData[i + 9] = (byte) t;
3310: t = 0;
3311: for (int x = 16; x < 24; x++) {
3312: t = t << 2 | (a[j + 3 * x + (y >> 3)] >> (~y & 7) & 1) * 3;
3313: }
3314: gaijiData[i + 4] = gaijiData[i + 10] = (byte) (t >> 8);
3315: gaijiData[i + 5] = gaijiData[i + 11] = (byte) t;
3316: i += 12;
3317: }
3318: }
3319:
3320:
3321:
3322:
3323:
3324:
3325:
3326:
3327:
3328: public static void prnSetRightMargin (int n) {
3329: if (prnCurrentPaper == null) {
3330: prnFeedPaper ();
3331: }
3332: if (0 <= n && n <= 999) {
3333: int rightX = prnGetCharacterWidth () * n;
3334: if (prnMarginLeftX < rightX) {
3335: prnMarginRightX = rightX;
3336:
3337: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3338: prnHorizontalTabAnchor[k] = 0;
3339: }
3340: }
3341: }
3342: }
3343:
3344:
3345:
3346: public static void prnClearAllHorizontalTabAnchor () {
3347: if (prnCurrentPaper == null) {
3348: prnFeedPaper ();
3349: }
3350:
3351: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3352: prnHorizontalTabAnchor[k] = 0;
3353: }
3354: }
3355:
3356:
3357:
3358:
3359: public static void prnSetPageStartPosition () {
3360: if (prnCurrentPaper == null) {
3361: prnFeedPaper ();
3362: }
3363:
3364: prnPageStart = prnHeadY;
3365:
3366: prnContentTopY = prnPageStart;
3367: prnContentBottomY = Math.min (prnPageStart + prnPageLength - prnMarginBottomHeight,
3368: prnAliveBottomY - prnAliveTopY);
3369:
3370: prnHeadX = prnMarginLeftX;
3371: prnHeadY = prnContentTopY;
3372: prnHeadLine = 0;
3373: }
3374:
3375:
3376:
3377: public static void prnSetOneSixth () {
3378: prnLineHeight = 60;
3379: prnDefaultLineHeight = 60;
3380: }
3381:
3382:
3383:
3384: public static void prnSetOneEighth () {
3385: prnLineHeight = 45;
3386: prnDefaultLineHeight = 45;
3387: }
3388:
3389:
3390:
3391:
3392:
3393:
3394:
3395: public static void prnSetBottomMargin (int n) {
3396: if (prnCurrentPaper == null) {
3397: prnFeedPaper ();
3398: }
3399: if (0 <= n && n <= 99) {
3400: int height = prnLineHeight * n;
3401: if (height < prnPageLength) {
3402: prnMarginBottomHeight = height;
3403:
3404: prnContentBottomY = Math.min (prnPageStart + prnPageLength - height,
3405: prnAliveBottomY - prnAliveTopY);
3406:
3407: if (prnContentBottomY <= prnHeadY) {
3408:
3409: prnPrintFormFeed ();
3410: }
3411:
3412: for (int k = 0; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
3413: prnVerticalTabAnchor[k] = 0;
3414: }
3415: }
3416: }
3417: }
3418:
3419:
3420:
3421:
3422:
3423: public static void prnSetEliteCharacterMode () {
3424: prnCharacterType = PRN_ELITE;
3425: }
3426:
3427:
3428:
3429:
3430:
3431:
3432:
3433: public static void prnSetPageHeight (int n) {
3434: if (prnCurrentPaper == null) {
3435: prnFeedPaper ();
3436: }
3437: prnSetPageStartPosition ();
3438: if (1 <= n && n <= 99) {
3439:
3440: prnPageLength = 180 * n;
3441:
3442: prnMarginBottomHeight = 0;
3443:
3444: prnSetPageStartPosition ();
3445: }
3446: }
3447:
3448:
3449:
3450:
3451:
3452:
3453:
3454:
3455: public static void prn16DotBitImage (byte[] a, int o, int n) {
3456: if (prnCurrentPaper == null) {
3457: prnFeedPaper ();
3458: }
3459:
3460: if (prnLineHeight == 45) {
3461: prnLineHeight = 48;
3462: }
3463: if (!prnHorizontalDoubleSizeMode) {
3464: if (!prnVerticalDoubleSizeMode) {
3465:
3466: int aw = n;
3467: int ah = 16;
3468: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
3469: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
3470: int bi = prnCheckRect (3 * aw, 3 * ah);
3471: if (0 <= bi) {
3472: int ix = prnIncrementX;
3473: int iy = prnIncrementY;
3474: for (int ay = 0; ay < ah; ay++) {
3475: int i = bi;
3476: for (int ax = 0; ax < aw; ax++) {
3477: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3478: prnBitmap[i ] &= (byte) prnCurrentColor;
3479: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3480: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3481: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3482: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3483: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3484: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3485: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3486: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3487: }
3488: i += 3 * ix;
3489: }
3490: bi += 3 * iy;
3491: }
3492: } else {
3493: for (int ay = 0; ay < ah; ay++) {
3494: for (int ax = 0; ax < aw; ax++) {
3495: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3496: prnPaintDot (3 * ax , 3 * ay );
3497: prnPaintDot (3 * ax + 1, 3 * ay );
3498: prnPaintDot (3 * ax + 2, 3 * ay );
3499: prnPaintDot (3 * ax , 3 * ay + 1);
3500: prnPaintDot (3 * ax + 1, 3 * ay + 1);
3501: prnPaintDot (3 * ax + 2, 3 * ay + 1);
3502: prnPaintDot (3 * ax , 3 * ay + 2);
3503: prnPaintDot (3 * ax + 1, 3 * ay + 2);
3504: prnPaintDot (3 * ax + 2, 3 * ay + 2);
3505: }
3506: }
3507: }
3508: }
3509: prnHeadX += 3 * aw;
3510: } else {
3511:
3512: int aw = n;
3513: int ah = 16;
3514: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
3515: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
3516: int bi = prnCheckRect (3 * aw, 6 * ah);
3517: if (0 <= bi) {
3518: int ix = prnIncrementX;
3519: int iy = prnIncrementY;
3520: for (int ay = 0; ay < ah; ay++) {
3521: int i = bi;
3522: for (int ax = 0; ax < aw; ax++) {
3523: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3524: prnBitmap[i ] &= (byte) prnCurrentColor;
3525: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3526: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3527: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3528: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3529: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3530: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3531: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3532: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3533: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3534: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3535: prnBitmap[i + 2 * ix * 3 * iy] &= (byte) prnCurrentColor;
3536: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
3537: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
3538: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
3539: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
3540: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
3541: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
3542: }
3543: i += 3 * ix;
3544: }
3545: bi += 6 * iy;
3546: }
3547: } else {
3548: for (int ay = 0; ay < ah; ay++) {
3549: for (int ax = 0; ax < aw; ax++) {
3550: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3551: prnPaintDot (3 * ax , 6 * ay );
3552: prnPaintDot (3 * ax + 1, 6 * ay );
3553: prnPaintDot (3 * ax + 2, 6 * ay );
3554: prnPaintDot (3 * ax , 6 * ay + 1);
3555: prnPaintDot (3 * ax + 1, 6 * ay + 1);
3556: prnPaintDot (3 * ax + 2, 6 * ay + 1);
3557: prnPaintDot (3 * ax , 6 * ay + 2);
3558: prnPaintDot (3 * ax + 1, 6 * ay + 2);
3559: prnPaintDot (3 * ax + 2, 6 * ay + 2);
3560: prnPaintDot (3 * ax , 6 * ay + 3);
3561: prnPaintDot (3 * ax + 1, 6 * ay + 3);
3562: prnPaintDot (3 * ax + 2, 6 * ay + 3);
3563: prnPaintDot (3 * ax , 6 * ay + 4);
3564: prnPaintDot (3 * ax + 1, 6 * ay + 4);
3565: prnPaintDot (3 * ax + 2, 6 * ay + 4);
3566: prnPaintDot (3 * ax , 6 * ay + 5);
3567: prnPaintDot (3 * ax + 1, 6 * ay + 5);
3568: prnPaintDot (3 * ax + 2, 6 * ay + 5);
3569: }
3570: }
3571: }
3572: }
3573: prnHeadX += 3 * aw;
3574: }
3575: } else {
3576: if (!prnVerticalDoubleSizeMode) {
3577:
3578: int aw = n;
3579: int ah = 16;
3580: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
3581: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
3582: int bi = prnCheckRect (6 * aw, 3 * ah);
3583: if (0 <= bi) {
3584: int ix = prnIncrementX;
3585: int iy = prnIncrementY;
3586: for (int ay = 0; ay < ah; ay++) {
3587: int i = bi;
3588: for (int ax = 0; ax < aw; ax++) {
3589: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3590: prnBitmap[i ] &= (byte) prnCurrentColor;
3591: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3592: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3593: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3594: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
3595: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
3596: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3597: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3598: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3599: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3600: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
3601: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
3602: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3603: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3604: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3605: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
3606: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
3607: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
3608: }
3609: i += 6 * ix;
3610: }
3611: bi += 3 * iy;
3612: }
3613: } else {
3614: for (int ay = 0; ay < ah; ay++) {
3615: for (int ax = 0; ax < aw; ax++) {
3616: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3617: prnPaintDot (6 * ax , 3 * ay );
3618: prnPaintDot (6 * ax + 1, 3 * ay );
3619: prnPaintDot (6 * ax + 2, 3 * ay );
3620: prnPaintDot (6 * ax + 3, 3 * ay );
3621: prnPaintDot (6 * ax + 4, 3 * ay );
3622: prnPaintDot (6 * ax + 5, 3 * ay );
3623: prnPaintDot (6 * ax , 3 * ay + 1);
3624: prnPaintDot (6 * ax + 1, 3 * ay + 1);
3625: prnPaintDot (6 * ax + 2, 3 * ay + 1);
3626: prnPaintDot (6 * ax + 3, 3 * ay + 1);
3627: prnPaintDot (6 * ax + 4, 3 * ay + 1);
3628: prnPaintDot (6 * ax + 5, 3 * ay + 1);
3629: prnPaintDot (6 * ax , 3 * ay + 2);
3630: prnPaintDot (6 * ax + 1, 3 * ay + 2);
3631: prnPaintDot (6 * ax + 2, 3 * ay + 2);
3632: prnPaintDot (6 * ax + 3, 3 * ay + 2);
3633: prnPaintDot (6 * ax + 4, 3 * ay + 2);
3634: prnPaintDot (6 * ax + 5, 3 * ay + 2);
3635: }
3636: }
3637: }
3638: }
3639: prnHeadX += 6 * aw;
3640: } else {
3641:
3642: int aw = n;
3643: int ah = 16;
3644: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
3645: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
3646: int bi = prnCheckRect (6 * aw, 6 * ah);
3647: if (0 <= bi) {
3648: int ix = prnIncrementX;
3649: int iy = prnIncrementY;
3650: for (int ay = 0; ay < ah; ay++) {
3651: int i = bi;
3652: for (int ax = 0; ax < aw; ax++) {
3653: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3654: prnBitmap[i ] &= (byte) prnCurrentColor;
3655: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3656: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3657: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3658: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
3659: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
3660: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3661: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3662: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3663: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3664: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
3665: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
3666: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3667: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3668: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3669: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
3670: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
3671: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
3672: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3673: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3674: prnBitmap[i + 2 * ix * 3 * iy] &= (byte) prnCurrentColor;
3675: prnBitmap[i + 3 * ix * 3 * iy] &= (byte) prnCurrentColor;
3676: prnBitmap[i + 4 * ix * 3 * iy] &= (byte) prnCurrentColor;
3677: prnBitmap[i + 5 * ix * 3 * iy] &= (byte) prnCurrentColor;
3678: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
3679: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
3680: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
3681: prnBitmap[i + 3 * ix + 4 * iy] &= (byte) prnCurrentColor;
3682: prnBitmap[i + 4 * ix + 4 * iy] &= (byte) prnCurrentColor;
3683: prnBitmap[i + 5 * ix + 4 * iy] &= (byte) prnCurrentColor;
3684: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
3685: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
3686: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
3687: prnBitmap[i + 3 * ix + 5 * iy] &= (byte) prnCurrentColor;
3688: prnBitmap[i + 4 * ix + 5 * iy] &= (byte) prnCurrentColor;
3689: prnBitmap[i + 5 * ix + 5 * iy] &= (byte) prnCurrentColor;
3690: }
3691: i += 6 * ix;
3692: }
3693: bi += 6 * iy;
3694: }
3695: } else {
3696: for (int ay = 0; ay < ah; ay++) {
3697: for (int ax = 0; ax < aw; ax++) {
3698: if ((a[o + 2 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3699: prnPaintDot (6 * ax , 6 * ay );
3700: prnPaintDot (6 * ax + 1, 6 * ay );
3701: prnPaintDot (6 * ax + 2, 6 * ay );
3702: prnPaintDot (6 * ax + 3, 6 * ay );
3703: prnPaintDot (6 * ax + 4, 6 * ay );
3704: prnPaintDot (6 * ax + 5, 6 * ay );
3705: prnPaintDot (6 * ax , 6 * ay + 1);
3706: prnPaintDot (6 * ax + 1, 6 * ay + 1);
3707: prnPaintDot (6 * ax + 2, 6 * ay + 1);
3708: prnPaintDot (6 * ax + 3, 6 * ay + 1);
3709: prnPaintDot (6 * ax + 4, 6 * ay + 1);
3710: prnPaintDot (6 * ax + 5, 6 * ay + 1);
3711: prnPaintDot (6 * ax , 6 * ay + 2);
3712: prnPaintDot (6 * ax + 1, 6 * ay + 2);
3713: prnPaintDot (6 * ax + 2, 6 * ay + 2);
3714: prnPaintDot (6 * ax + 3, 6 * ay + 2);
3715: prnPaintDot (6 * ax + 4, 6 * ay + 2);
3716: prnPaintDot (6 * ax + 5, 6 * ay + 2);
3717: prnPaintDot (6 * ax , 6 * ay + 3);
3718: prnPaintDot (6 * ax + 1, 6 * ay + 3);
3719: prnPaintDot (6 * ax + 2, 6 * ay + 3);
3720: prnPaintDot (6 * ax + 3, 6 * ay + 3);
3721: prnPaintDot (6 * ax + 4, 6 * ay + 3);
3722: prnPaintDot (6 * ax + 5, 6 * ay + 3);
3723: prnPaintDot (6 * ax , 6 * ay + 4);
3724: prnPaintDot (6 * ax + 1, 6 * ay + 4);
3725: prnPaintDot (6 * ax + 2, 6 * ay + 4);
3726: prnPaintDot (6 * ax + 3, 6 * ay + 4);
3727: prnPaintDot (6 * ax + 4, 6 * ay + 4);
3728: prnPaintDot (6 * ax + 5, 6 * ay + 4);
3729: prnPaintDot (6 * ax , 6 * ay + 5);
3730: prnPaintDot (6 * ax + 1, 6 * ay + 5);
3731: prnPaintDot (6 * ax + 2, 6 * ay + 5);
3732: prnPaintDot (6 * ax + 3, 6 * ay + 5);
3733: prnPaintDot (6 * ax + 4, 6 * ay + 5);
3734: prnPaintDot (6 * ax + 5, 6 * ay + 5);
3735: }
3736: }
3737: }
3738: }
3739: prnHeadX += 6 * aw;
3740: }
3741: }
3742:
3743: prnPrinted = true;
3744:
3745: if (prnCanvas != null) {
3746: prnCanvas.repaint ();
3747: }
3748: }
3749:
3750:
3751:
3752:
3753:
3754:
3755:
3756:
3757: public static void prn24DotBitImage (byte[] a, int o, int n) {
3758: if (prnCurrentPaper == null) {
3759: prnFeedPaper ();
3760: }
3761:
3762: if (prnLineHeight == 45) {
3763: prnLineHeight = 48;
3764: }
3765: if (!prnHorizontalDoubleSizeMode) {
3766: if (!prnVerticalDoubleSizeMode) {
3767:
3768: int aw = n;
3769: int ah = 24;
3770: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
3771: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
3772: int bi = prnCheckRect (2 * aw, 2 * ah);
3773: if (0 <= bi) {
3774: int ix = prnIncrementX;
3775: int iy = prnIncrementY;
3776: for (int ay = 0; ay < ah; ay++) {
3777: int i = bi;
3778: for (int ax = 0; ax < aw; ax++) {
3779: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3780: prnBitmap[i ] &= (byte) prnCurrentColor;
3781: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3782: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3783: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3784: }
3785: i += 2 * ix;
3786: }
3787: bi += 2 * iy;
3788: }
3789: } else {
3790: for (int ay = 0; ay < ah; ay++) {
3791: for (int ax = 0; ax < aw; ax++) {
3792: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3793: prnPaintDot (2 * ax , 2 * ay );
3794: prnPaintDot (2 * ax + 1, 2 * ay );
3795: prnPaintDot (2 * ax , 2 * ay + 1);
3796: prnPaintDot (2 * ax + 1, 2 * ay + 1);
3797: }
3798: }
3799: }
3800: }
3801: prnHeadX += 2 * aw;
3802: } else {
3803:
3804: int aw = n;
3805: int ah = 24;
3806: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
3807: ah = Math.min (4 * ah, prnContentBottomY - prnHeadY) >> 2;
3808: int bi = prnCheckRect (2 * aw, 4 * ah);
3809: if (0 <= bi) {
3810: int ix = prnIncrementX;
3811: int iy = prnIncrementY;
3812: for (int ay = 0; ay < ah; ay++) {
3813: int i = bi;
3814: for (int ax = 0; ax < aw; ax++) {
3815: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3816: prnBitmap[i ] &= (byte) prnCurrentColor;
3817: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3818: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3819: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3820: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3821: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3822: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3823: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3824: }
3825: i += 2 * ix;
3826: }
3827: bi += 4 * iy;
3828: }
3829: } else {
3830: for (int ay = 0; ay < ah; ay++) {
3831: for (int ax = 0; ax < aw; ax++) {
3832: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3833: prnPaintDot (2 * ax , 4 * ay );
3834: prnPaintDot (2 * ax + 1, 4 * ay );
3835: prnPaintDot (2 * ax , 4 * ay + 1);
3836: prnPaintDot (2 * ax + 1, 4 * ay + 1);
3837: prnPaintDot (2 * ax , 4 * ay + 2);
3838: prnPaintDot (2 * ax + 1, 4 * ay + 2);
3839: prnPaintDot (2 * ax , 4 * ay + 3);
3840: prnPaintDot (2 * ax + 1, 4 * ay + 3);
3841: }
3842: }
3843: }
3844: }
3845: prnHeadX += 2 * aw;
3846: }
3847: } else {
3848: if (!prnVerticalDoubleSizeMode) {
3849:
3850: int aw = n;
3851: int ah = 24;
3852: aw = Math.min (4 * aw, prnMarginRightX - prnHeadX) >> 2;
3853: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
3854: int bi = prnCheckRect (4 * aw, 2 * ah);
3855: if (0 <= bi) {
3856: int ix = prnIncrementX;
3857: int iy = prnIncrementY;
3858: for (int ay = 0; ay < ah; ay++) {
3859: int i = bi;
3860: for (int ax = 0; ax < aw; ax++) {
3861: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3862: prnBitmap[i ] &= (byte) prnCurrentColor;
3863: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3864: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3865: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3866: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3867: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3868: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3869: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3870: }
3871: i += 4 * ix;
3872: }
3873: bi += 2 * iy;
3874: }
3875: } else {
3876: for (int ay = 0; ay < ah; ay++) {
3877: for (int ax = 0; ax < aw; ax++) {
3878: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3879: prnPaintDot (4 * ax , 2 * ay );
3880: prnPaintDot (4 * ax + 1, 2 * ay );
3881: prnPaintDot (4 * ax + 2, 2 * ay );
3882: prnPaintDot (4 * ax + 3, 2 * ay );
3883: prnPaintDot (4 * ax , 2 * ay + 1);
3884: prnPaintDot (4 * ax + 1, 2 * ay + 1);
3885: prnPaintDot (4 * ax + 2, 2 * ay + 1);
3886: prnPaintDot (4 * ax + 3, 2 * ay + 1);
3887: }
3888: }
3889: }
3890: }
3891: prnHeadX += 4 * aw;
3892: } else {
3893:
3894: int aw = n;
3895: int ah = 24;
3896: aw = Math.min (4 * aw, prnMarginRightX - prnHeadX) >> 2;
3897: ah = Math.min (4 * ah, prnContentBottomY - prnHeadY) >> 2;
3898: int bi = prnCheckRect (4 * aw, 4 * ah);
3899: if (0 <= bi) {
3900: int ix = prnIncrementX;
3901: int iy = prnIncrementY;
3902: for (int ay = 0; ay < ah; ay++) {
3903: int i = bi;
3904: for (int ax = 0; ax < aw; ax++) {
3905: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3906: prnBitmap[i ] &= (byte) prnCurrentColor;
3907: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
3908: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
3909: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
3910: prnBitmap[i + iy] &= (byte) prnCurrentColor;
3911: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
3912: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
3913: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
3914: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
3915: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
3916: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
3917: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
3918: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
3919: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
3920: prnBitmap[i + 2 * ix + 3 * iy] &= (byte) prnCurrentColor;
3921: prnBitmap[i + 3 * ix + 3 * iy] &= (byte) prnCurrentColor;
3922: }
3923: i += 4 * ix;
3924: }
3925: bi += 4 * iy;
3926: }
3927: } else {
3928: for (int ay = 0; ay < ah; ay++) {
3929: for (int ax = 0; ax < aw; ax++) {
3930: if ((a[o + 3 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
3931: prnPaintDot (4 * ax , 4 * ay );
3932: prnPaintDot (4 * ax + 1, 4 * ay );
3933: prnPaintDot (4 * ax + 2, 4 * ay );
3934: prnPaintDot (4 * ax + 3, 4 * ay );
3935: prnPaintDot (4 * ax , 4 * ay + 1);
3936: prnPaintDot (4 * ax + 1, 4 * ay + 1);
3937: prnPaintDot (4 * ax + 2, 4 * ay + 1);
3938: prnPaintDot (4 * ax + 3, 4 * ay + 1);
3939: prnPaintDot (4 * ax , 4 * ay + 2);
3940: prnPaintDot (4 * ax + 1, 4 * ay + 2);
3941: prnPaintDot (4 * ax + 2, 4 * ay + 2);
3942: prnPaintDot (4 * ax + 3, 4 * ay + 2);
3943: prnPaintDot (4 * ax , 4 * ay + 3);
3944: prnPaintDot (4 * ax + 1, 4 * ay + 3);
3945: prnPaintDot (4 * ax + 2, 4 * ay + 3);
3946: prnPaintDot (4 * ax + 3, 4 * ay + 3);
3947: }
3948: }
3949: }
3950: }
3951: prnHeadX += 4 * aw;
3952: }
3953: }
3954:
3955: prnPrinted = true;
3956:
3957: if (prnCanvas != null) {
3958: prnCanvas.repaint ();
3959: }
3960: }
3961:
3962:
3963:
3964:
3965:
3966: public static void prnSetKanjiMode (boolean b) {
3967: prnKanjiMode = b;
3968: }
3969:
3970:
3971:
3972:
3973:
3974:
3975:
3976:
3977:
3978: public static void prnSetLeftMargin (int n) {
3979: if (prnCurrentPaper == null) {
3980: prnFeedPaper ();
3981: }
3982: if (0 <= n && n <= 999) {
3983: int leftX = prnGetCharacterWidth () * n;
3984: if (leftX < prnMarginRightX) {
3985: prnMarginLeftX = leftX;
3986: if (prnHeadX < prnMarginLeftX) {
3987: prnHeadX = prnMarginLeftX;
3988: }
3989:
3990: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
3991: prnHorizontalTabAnchor[k] = 0;
3992: }
3993: }
3994: }
3995: }
3996:
3997:
3998:
3999:
4000:
4001:
4002:
4003: public static void prn48DotBitImage (byte[] a, int o, int n) {
4004: if (prnCurrentPaper == null) {
4005: prnFeedPaper ();
4006: }
4007:
4008: if (prnLineHeight == 45) {
4009: prnLineHeight = 47;
4010: }
4011: if (!prnHorizontalDoubleSizeMode) {
4012: if (!prnVerticalDoubleSizeMode) {
4013:
4014: int aw = n;
4015: int ah = 48;
4016: aw = Math.min (aw, prnMarginRightX - prnHeadX);
4017: ah = Math.min (ah, prnContentBottomY - prnHeadY);
4018: int bi = prnCheckRect ( aw, ah);
4019: if (0 <= bi) {
4020: int ix = prnIncrementX;
4021: int iy = prnIncrementY;
4022: for (int ay = 0; ay < ah; ay++) {
4023: int i = bi;
4024: for (int ax = 0; ax < aw; ax++) {
4025: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4026: prnBitmap[i ] &= (byte) prnCurrentColor;
4027: }
4028: i += ix;
4029: }
4030: bi += iy;
4031: }
4032: } else {
4033: for (int ay = 0; ay < ah; ay++) {
4034: for (int ax = 0; ax < aw; ax++) {
4035: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4036: prnPaintDot ( ax , ay );
4037: }
4038: }
4039: }
4040: }
4041: prnHeadX += aw;
4042: } else {
4043:
4044: int aw = n;
4045: int ah = 48;
4046: aw = Math.min (aw, prnMarginRightX - prnHeadX);
4047: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
4048: int bi = prnCheckRect ( aw, 2 * ah);
4049: if (0 <= bi) {
4050: int ix = prnIncrementX;
4051: int iy = prnIncrementY;
4052: for (int ay = 0; ay < ah; ay++) {
4053: int i = bi;
4054: for (int ax = 0; ax < aw; ax++) {
4055: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4056: prnBitmap[i ] &= (byte) prnCurrentColor;
4057: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4058: }
4059: i += ix;
4060: }
4061: bi += 2 * iy;
4062: }
4063: } else {
4064: for (int ay = 0; ay < ah; ay++) {
4065: for (int ax = 0; ax < aw; ax++) {
4066: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4067: prnPaintDot ( ax , 2 * ay );
4068: prnPaintDot ( ax , 2 * ay + 1);
4069: }
4070: }
4071: }
4072: }
4073: prnHeadX += aw;
4074: }
4075: } else {
4076: if (!prnVerticalDoubleSizeMode) {
4077:
4078: int aw = n;
4079: int ah = 48;
4080: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
4081: ah = Math.min (ah, prnContentBottomY - prnHeadY);
4082: int bi = prnCheckRect (2 * aw, ah);
4083: if (0 <= bi) {
4084: int ix = prnIncrementX;
4085: int iy = prnIncrementY;
4086: for (int ay = 0; ay < ah; ay++) {
4087: int i = bi;
4088: for (int ax = 0; ax < aw; ax++) {
4089: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4090: prnBitmap[i ] &= (byte) prnCurrentColor;
4091: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4092: }
4093: i += 2 * ix;
4094: }
4095: bi += iy;
4096: }
4097: } else {
4098: for (int ay = 0; ay < ah; ay++) {
4099: for (int ax = 0; ax < aw; ax++) {
4100: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4101: prnPaintDot (2 * ax , ay );
4102: prnPaintDot (2 * ax + 1, ay );
4103: }
4104: }
4105: }
4106: }
4107: prnHeadX += 2 * aw;
4108: } else {
4109:
4110: int aw = n;
4111: int ah = 24;
4112: aw = Math.min (2 * aw, prnMarginRightX - prnHeadX) >> 1;
4113: ah = Math.min (2 * ah, prnContentBottomY - prnHeadY) >> 1;
4114: int bi = prnCheckRect (2 * aw, 2 * ah);
4115: if (0 <= bi) {
4116: int ix = prnIncrementX;
4117: int iy = prnIncrementY;
4118: for (int ay = 0; ay < ah; ay++) {
4119: int i = bi;
4120: for (int ax = 0; ax < aw; ax++) {
4121: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4122: prnBitmap[i ] &= (byte) prnCurrentColor;
4123: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4124: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4125: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4126: }
4127: i += 2 * ix;
4128: }
4129: bi += 2 * iy;
4130: }
4131: } else {
4132: for (int ay = 0; ay < ah; ay++) {
4133: for (int ax = 0; ax < aw; ax++) {
4134: if ((a[o + 6 * ax + (ay >> 3)] >> (~ay & 7) & 1) != 0) {
4135: prnPaintDot (2 * ax , 2 * ay );
4136: prnPaintDot (2 * ax + 1, 2 * ay );
4137: prnPaintDot (2 * ax , 2 * ay + 1);
4138: prnPaintDot (2 * ax + 1, 2 * ay + 1);
4139: }
4140: }
4141: }
4142: }
4143: prnHeadX += 2 * aw;
4144: }
4145: }
4146:
4147: prnPrinted = true;
4148:
4149: if (prnCanvas != null) {
4150: prnCanvas.repaint ();
4151: }
4152: }
4153:
4154:
4155:
4156:
4157:
4158: public static void prnRepeatCharacter (int n, int d) {
4159: if (prnCurrentPaper == null) {
4160: prnFeedPaper ();
4161: }
4162: if (0x20 <= d) {
4163: for (int i = 0; i < n; i++) {
4164: prnPrintCharacter (d);
4165: }
4166: }
4167: }
4168:
4169:
4170:
4171:
4172: public static void prnSetSmallCharacterMode () {
4173: prnCharacterType = PRN_SMALL;
4174: }
4175:
4176:
4177:
4178:
4179:
4180: public static void prnSetPicaCharacterMode () {
4181: prnCharacterType = PRN_PICA;
4182: }
4183:
4184:
4185:
4186: public static void prnRepeat8DotBitImage (int n, int d) {
4187: if (prnCurrentPaper == null) {
4188: prnFeedPaper ();
4189: }
4190:
4191: }
4192:
4193:
4194:
4195: public static void prnRepeat16DotBitImage (int n, int d) {
4196: if (prnCurrentPaper == null) {
4197: prnFeedPaper ();
4198: }
4199:
4200: if (prnLineHeight == 45) {
4201: prnLineHeight = 48;
4202: }
4203: if (!prnHorizontalDoubleSizeMode) {
4204: if (!prnVerticalDoubleSizeMode) {
4205:
4206: int aw = n;
4207: int ah = 16;
4208: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
4209: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
4210: int bi = prnCheckRect (3 * aw, 3 * ah);
4211: if (0 <= bi) {
4212: int ix = prnIncrementX;
4213: int iy = prnIncrementY;
4214: for (int ay = 0; ay < ah; ay++) {
4215: int i = bi;
4216: for (int ax = 0; ax < aw; ax++) {
4217: if ((d >> (~ay & 15) & 1) != 0) {
4218: prnBitmap[i ] &= (byte) prnCurrentColor;
4219: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4220: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4221: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4222: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4223: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4224: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4225: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4226: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4227: }
4228: i += 3 * ix;
4229: }
4230: bi += 3 * iy;
4231: }
4232: } else {
4233: for (int ay = 0; ay < ah; ay++) {
4234: for (int ax = 0; ax < aw; ax++) {
4235: if ((d >> (~ay & 15) & 1) != 0) {
4236: prnPaintDot (3 * ax , 3 * ay );
4237: prnPaintDot (3 * ax + 1, 3 * ay );
4238: prnPaintDot (3 * ax + 2, 3 * ay );
4239: prnPaintDot (3 * ax , 3 * ay + 1);
4240: prnPaintDot (3 * ax + 1, 3 * ay + 1);
4241: prnPaintDot (3 * ax + 2, 3 * ay + 1);
4242: prnPaintDot (3 * ax , 3 * ay + 2);
4243: prnPaintDot (3 * ax + 1, 3 * ay + 2);
4244: prnPaintDot (3 * ax + 2, 3 * ay + 2);
4245: }
4246: }
4247: }
4248: }
4249: prnHeadX += 3 * aw;
4250: } else {
4251:
4252: int aw = n;
4253: int ah = 16;
4254: aw = Math.min (3 * aw, prnMarginRightX - prnHeadX) / 3;
4255: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
4256: int bi = prnCheckRect (3 * aw, 6 * ah);
4257: if (0 <= bi) {
4258: int ix = prnIncrementX;
4259: int iy = prnIncrementY;
4260: for (int ay = 0; ay < ah; ay++) {
4261: int i = bi;
4262: for (int ax = 0; ax < aw; ax++) {
4263: if ((d >> (~ay & 15) & 1) != 0) {
4264: prnBitmap[i ] &= (byte) prnCurrentColor;
4265: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4266: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4267: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4268: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4269: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4270: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4271: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4272: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4273: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
4274: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
4275: prnBitmap[i + 2 * ix + 3 * iy] &= (byte) prnCurrentColor;
4276: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
4277: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
4278: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
4279: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
4280: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
4281: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
4282: }
4283: i += 3 * ix;
4284: }
4285: bi += 6 * iy;
4286: }
4287: } else {
4288: for (int ay = 0; ay < ah; ay++) {
4289: for (int ax = 0; ax < aw; ax++) {
4290: if ((d >> (~ay & 15) & 1) != 0) {
4291: prnPaintDot (3 * ax , 6 * ay );
4292: prnPaintDot (3 * ax + 1, 6 * ay );
4293: prnPaintDot (3 * ax + 2, 6 * ay );
4294: prnPaintDot (3 * ax , 6 * ay + 1);
4295: prnPaintDot (3 * ax + 1, 6 * ay + 1);
4296: prnPaintDot (3 * ax + 2, 6 * ay + 1);
4297: prnPaintDot (3 * ax , 6 * ay + 2);
4298: prnPaintDot (3 * ax + 1, 6 * ay + 2);
4299: prnPaintDot (3 * ax + 2, 6 * ay + 2);
4300: prnPaintDot (3 * ax , 6 * ay + 3);
4301: prnPaintDot (3 * ax + 1, 6 * ay + 3);
4302: prnPaintDot (3 * ax + 2, 6 * ay + 3);
4303: prnPaintDot (3 * ax , 6 * ay + 4);
4304: prnPaintDot (3 * ax + 1, 6 * ay + 4);
4305: prnPaintDot (3 * ax + 2, 6 * ay + 4);
4306: prnPaintDot (3 * ax , 6 * ay + 5);
4307: prnPaintDot (3 * ax + 1, 6 * ay + 5);
4308: prnPaintDot (3 * ax + 2, 6 * ay + 5);
4309: }
4310: }
4311: }
4312: }
4313: prnHeadX += 3 * aw;
4314: }
4315: } else {
4316: if (!prnVerticalDoubleSizeMode) {
4317:
4318: int aw = n;
4319: int ah = 16;
4320: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
4321: ah = Math.min (3 * ah, prnContentBottomY - prnHeadY) / 3;
4322: int bi = prnCheckRect (6 * aw, 3 * ah);
4323: if (0 <= bi) {
4324: int ix = prnIncrementX;
4325: int iy = prnIncrementY;
4326: for (int ay = 0; ay < ah; ay++) {
4327: int i = bi;
4328: for (int ax = 0; ax < aw; ax++) {
4329: if ((d >> (~ay & 15) & 1) != 0) {
4330: prnBitmap[i ] &= (byte) prnCurrentColor;
4331: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4332: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4333: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
4334: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
4335: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
4336: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4337: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4338: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4339: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
4340: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
4341: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
4342: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4343: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4344: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4345: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
4346: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
4347: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
4348: }
4349: i += 6 * ix;
4350: }
4351: bi += 3 * iy;
4352: }
4353: } else {
4354: for (int ay = 0; ay < ah; ay++) {
4355: for (int ax = 0; ax < aw; ax++) {
4356: if ((d >> (~ay & 15) & 1) != 0) {
4357: prnPaintDot (6 * ax , 3 * ay );
4358: prnPaintDot (6 * ax + 1, 3 * ay );
4359: prnPaintDot (6 * ax + 2, 3 * ay );
4360: prnPaintDot (6 * ax + 3, 3 * ay );
4361: prnPaintDot (6 * ax + 4, 3 * ay );
4362: prnPaintDot (6 * ax + 5, 3 * ay );
4363: prnPaintDot (6 * ax , 3 * ay + 1);
4364: prnPaintDot (6 * ax + 1, 3 * ay + 1);
4365: prnPaintDot (6 * ax + 2, 3 * ay + 1);
4366: prnPaintDot (6 * ax + 3, 3 * ay + 1);
4367: prnPaintDot (6 * ax + 4, 3 * ay + 1);
4368: prnPaintDot (6 * ax + 5, 3 * ay + 1);
4369: prnPaintDot (6 * ax , 3 * ay + 2);
4370: prnPaintDot (6 * ax + 1, 3 * ay + 2);
4371: prnPaintDot (6 * ax + 2, 3 * ay + 2);
4372: prnPaintDot (6 * ax + 3, 3 * ay + 2);
4373: prnPaintDot (6 * ax + 4, 3 * ay + 2);
4374: prnPaintDot (6 * ax + 5, 3 * ay + 2);
4375: }
4376: }
4377: }
4378: }
4379: prnHeadX += 6 * aw;
4380: } else {
4381:
4382: int aw = n;
4383: int ah = 16;
4384: aw = Math.min (6 * aw, prnMarginRightX - prnHeadX) / 6;
4385: ah = Math.min (6 * ah, prnContentBottomY - prnHeadY) / 6;
4386: int bi = prnCheckRect (6 * aw, 6 * ah);
4387: if (0 <= bi) {
4388: int ix = prnIncrementX;
4389: int iy = prnIncrementY;
4390: for (int ay = 0; ay < ah; ay++) {
4391: int i = bi;
4392: for (int ax = 0; ax < aw; ax++) {
4393: if ((short) (d << (ay & 15)) < 0) {
4394: prnBitmap[i ] &= (byte) prnCurrentColor;
4395: prnBitmap[i + ix ] &= (byte) prnCurrentColor;
4396: prnBitmap[i + 2 * ix ] &= (byte) prnCurrentColor;
4397: prnBitmap[i + 3 * ix ] &= (byte) prnCurrentColor;
4398: prnBitmap[i + 4 * ix ] &= (byte) prnCurrentColor;
4399: prnBitmap[i + 5 * ix ] &= (byte) prnCurrentColor;
4400: prnBitmap[i + iy] &= (byte) prnCurrentColor;
4401: prnBitmap[i + ix + iy] &= (byte) prnCurrentColor;
4402: prnBitmap[i + 2 * ix + iy] &= (byte) prnCurrentColor;
4403: prnBitmap[i + 3 * ix + iy] &= (byte) prnCurrentColor;
4404: prnBitmap[i + 4 * ix + iy] &= (byte) prnCurrentColor;
4405: prnBitmap[i + 5 * ix + iy] &= (byte) prnCurrentColor;
4406: prnBitmap[i + 2 * iy] &= (byte) prnCurrentColor;
4407: prnBitmap[i + ix + 2 * iy] &= (byte) prnCurrentColor;
4408: prnBitmap[i + 2 * ix + 2 * iy] &= (byte) prnCurrentColor;
4409: prnBitmap[i + 3 * ix + 2 * iy] &= (byte) prnCurrentColor;
4410: prnBitmap[i + 4 * ix + 2 * iy] &= (byte) prnCurrentColor;
4411: prnBitmap[i + 5 * ix + 2 * iy] &= (byte) prnCurrentColor;
4412: prnBitmap[i + 3 * iy] &= (byte) prnCurrentColor;
4413: prnBitmap[i + ix + 3 * iy] &= (byte) prnCurrentColor;
4414: prnBitmap[i + 2 * ix + 3 * iy] &= (byte) prnCurrentColor;
4415: prnBitmap[i + 3 * ix + 3 * iy] &= (byte) prnCurrentColor;
4416: prnBitmap[i + 4 * ix + 3 * iy] &= (byte) prnCurrentColor;
4417: prnBitmap[i + 5 * ix + 3 * iy] &= (byte) prnCurrentColor;
4418: prnBitmap[i + 4 * iy] &= (byte) prnCurrentColor;
4419: prnBitmap[i + ix + 4 * iy] &= (byte) prnCurrentColor;
4420: prnBitmap[i + 2 * ix + 4 * iy] &= (byte) prnCurrentColor;
4421: prnBitmap[i + 3 * ix + 4 * iy] &= (byte) prnCurrentColor;
4422: prnBitmap[i + 4 * ix + 4 * iy] &= (byte) prnCurrentColor;
4423: prnBitmap[i + 5 * ix + 4 * iy] &= (byte) prnCurrentColor;
4424: prnBitmap[i + 5 * iy] &= (byte) prnCurrentColor;
4425: prnBitmap[i + ix + 5 * iy] &= (byte) prnCurrentColor;
4426: prnBitmap[i + 2 * ix + 5 * iy] &= (byte) prnCurrentColor;
4427: prnBitmap[i + 3 * ix + 5 * iy] &= (byte) prnCurrentColor;
4428: prnBitmap[i + 4 * ix + 5 * iy] &= (byte) prnCurrentColor;
4429: prnBitmap[i + 5 * ix + 5 * iy] &= (byte) prnCurrentColor;
4430: }
4431: i += 6 * ix;
4432: }
4433: bi += 6 * iy;
4434: }
4435: } else {
4436: for (int ay = 0; ay < ah; ay++) {
4437: for (int ax = 0; ax < aw; ax++) {
4438: if ((short) (d << (ay & 15)) < 0) {
4439: prnPaintDot (6 * ax , 6 * ay );
4440: prnPaintDot (6 * ax + 1, 6 * ay );
4441: prnPaintDot (6 * ax + 2, 6 * ay );
4442: prnPaintDot (6 * ax + 3, 6 * ay );
4443: prnPaintDot (6 * ax + 4, 6 * ay );
4444: prnPaintDot (6 * ax + 5, 6 * ay );
4445: prnPaintDot (6 * ax , 6 * ay + 1);
4446: prnPaintDot (6 * ax + 1, 6 * ay + 1);
4447: prnPaintDot (6 * ax + 2, 6 * ay + 1);
4448: prnPaintDot (6 * ax + 3, 6 * ay + 1);
4449: prnPaintDot (6 * ax + 4, 6 * ay + 1);
4450: prnPaintDot (6 * ax + 5, 6 * ay + 1);
4451: prnPaintDot (6 * ax , 6 * ay + 2);
4452: prnPaintDot (6 * ax + 1, 6 * ay + 2);
4453: prnPaintDot (6 * ax + 2, 6 * ay + 2);
4454: prnPaintDot (6 * ax + 3, 6 * ay + 2);
4455: prnPaintDot (6 * ax + 4, 6 * ay + 2);
4456: prnPaintDot (6 * ax + 5, 6 * ay + 2);
4457: prnPaintDot (6 * ax , 6 * ay + 3);
4458: prnPaintDot (6 * ax + 1, 6 * ay + 3);
4459: prnPaintDot (6 * ax + 2, 6 * ay + 3);
4460: prnPaintDot (6 * ax + 3, 6 * ay + 3);
4461: prnPaintDot (6 * ax + 4, 6 * ay + 3);
4462: prnPaintDot (6 * ax + 5, 6 * ay + 3);
4463: prnPaintDot (6 * ax , 6 * ay + 4);
4464: prnPaintDot (6 * ax + 1, 6 * ay + 4);
4465: prnPaintDot (6 * ax + 2, 6 * ay + 4);
4466: prnPaintDot (6 * ax + 3, 6 * ay + 4);
4467: prnPaintDot (6 * ax + 4, 6 * ay + 4);
4468: prnPaintDot (6 * ax + 5, 6 * ay + 4);
4469: prnPaintDot (6 * ax , 6 * ay + 5);
4470: prnPaintDot (6 * ax + 1, 6 * ay + 5);
4471: prnPaintDot (6 * ax + 2, 6 * ay + 5);
4472: prnPaintDot (6 * ax + 3, 6 * ay + 5);
4473: prnPaintDot (6 * ax + 4, 6 * ay + 5);
4474: prnPaintDot (6 * ax + 5, 6 * ay + 5);
4475: }
4476: }
4477: }
4478: }
4479: prnHeadX += 6 * aw;
4480: }
4481: }
4482:
4483: prnPrinted = true;
4484:
4485: if (prnCanvas != null) {
4486: prnCanvas.repaint ();
4487: }
4488: }
4489:
4490:
4491:
4492:
4493: public static void prnSetUnderlineMode (boolean b) {
4494: prnUnderlineMode = b;
4495: }
4496:
4497:
4498:
4499:
4500:
4501:
4502: public static void prnHorizontalMove (int n) {
4503: if (prnCurrentPaper == null) {
4504: prnFeedPaper ();
4505: }
4506: if (-1440 <= n && n <= 1440) {
4507: int headX = prnHeadX + 2 * n;
4508: if (prnMarginLeftX <= headX && headX < prnMarginRightX) {
4509: prnHeadX = headX;
4510: }
4511: }
4512: }
4513:
4514:
4515:
4516: public static void prnResetSettings () {
4517: prnEjectPaper ();
4518:
4519: prnMarginLeftX = 0;
4520: prnMarginRightX = 2879;
4521: prnMarginBottomHeight = 0;
4522:
4523: prnDefaultLineHeight = 60;
4524: prnLineHeight = 60;
4525:
4526: prnCharacterType = PRN_PICA;
4527:
4528: prnHiraganaMode = false;
4529:
4530: prnScriptMode = PRN_NO_SCRIPT;
4531:
4532: prnStrongMode = false;
4533:
4534: prnUnderlineMode = false;
4535:
4536: prnCharacterStyle = PRN_NORMAL_STYLE;
4537:
4538: prnKanjiMode = false;
4539:
4540: if (prnGaijiData != null) {
4541: Arrays.fill (prnGaijiData, (byte) 0);
4542: }
4543:
4544: prnVerticalWritingMode = false;
4545:
4546: prnFullWidthLeftSpace = 2;
4547: prnFullWidthRightSpace = 6;
4548: prnHalfWidthLeftSpace = 0;
4549: prnHalfWidthRightSpace = 4;
4550:
4551: prnHorizontalDoubleSizeMode = false;
4552: prnVerticalDoubleSizeMode = false;
4553: prnKanjiHorizontalDoubleSizeMode = false;
4554:
4555: for (int k = 0; k < PRN_HORIZONTAL_ANCHOR_LIMIT; k++) {
4556: prnHorizontalTabAnchor[k] = 36 * 8 * (1 + k);
4557: }
4558:
4559: for (int k = 0; k < PRN_VERTICAL_ANCHOR_LIMIT; k++) {
4560: prnVerticalTabAnchor[k] = 0;
4561: }
4562:
4563: prnColorMode = false;
4564:
4565: prnHalfWidthFont =
4566: prnFullWidthFont = (prnDIPSW & PRN_DIPSW_FONT_STYLE) == 0 ? 0 : 1;
4567:
4568: prnCurrentColor = prnSingleColor;
4569:
4570: prnCommandLength = 1;
4571: prnCommandPointer = 0;
4572: }
4573:
4574:
4575:
4576:
4577:
4578: public static void prnSetHalfWidthFont (int n) {
4579: if (0 <= n && n <= 1) {
4580: prnHalfWidthFont = n;
4581: }
4582: }
4583:
4584:
4585:
4586:
4587:
4588: public static void prnSenseOutOfPaper (boolean b) {
4589:
4590: }
4591:
4592:
4593:
4594:
4595:
4596:
4597:
4598: public static void prnSetCharacterStyle (int n) {
4599: if (0 <= n && n <= 3) {
4600: prnCharacterStyle = n;
4601: }
4602: }
4603:
4604:
4605:
4606:
4607:
4608: public static void prnSetScriptMode (int n) {
4609: if (0 <= n && n <= 2) {
4610: prnScriptMode = n;
4611: }
4612: }
4613:
4614:
4615:
4616:
4617: public static void prnSetVerticalWritingMode (boolean b) {
4618: prnVerticalWritingMode = b;
4619: }
4620:
4621:
4622:
4623: public static void prnSetFullWidthLeftRightSpace (int l, int r) {
4624: prnFullWidthLeftSpace = l;
4625: prnFullWidthRightSpace = r;
4626: }
4627:
4628:
4629:
4630: public static void prnSetHalfWidthLeftRightSpace (int l, int r) {
4631: prnHalfWidthLeftSpace = l;
4632: prnHalfWidthRightSpace = r;
4633: }
4634:
4635:
4636:
4637:
4638:
4639: public static void prnSetFullWidthFont (int n) {
4640: if (0 <= n && n <= 1) {
4641: prnFullWidthFont = n;
4642: }
4643: }
4644:
4645:
4646:
4647:
4648: public static void prnSetKanjiHorizontalDoubleSizeMode (boolean b) {
4649: prnKanjiHorizontalDoubleSizeMode = b;
4650: }
4651:
4652:
4653:
4654:
4655:
4656:
4657:
4658:
4659: public static int prnCheckRect (int rw, int rh) {
4660: int px0 = prnAliveLeftX + prnHeadX;
4661: int py0 = prnAliveTopY + prnHeadY;
4662: int px1 = px0 + rw - 1;
4663: int py1 = py0 + rh - 1;
4664: int bx0 = prnM11 * px0 + prnM12 * py0 + prnM13;
4665: int by0 = prnM21 * px0 + prnM22 * py0 + prnM23;
4666: int bx1 = prnM11 * px1 + prnM12 * py1 + prnM13;
4667: int by1 = prnM21 * px1 + prnM22 * py1 + prnM23;
4668: return (0 <= bx0 && bx0 < prnRotatedWidthDot &&
4669: 0 <= by0 && by0 < prnRotatedHeightDot &&
4670: 0 <= bx1 && bx1 < prnRotatedWidthDot &&
4671: 0 <= by1 && by1 < prnRotatedHeightDot ?
4672: bx0 + prnRotatedWidthDot * by0 :
4673: -1);
4674: }
4675:
4676:
4677:
4678:
4679:
4680: public static void prnPaintDot (int rx, int ry) {
4681: int px = prnAliveLeftX + prnHeadX + rx;
4682: int py = prnAliveTopY + prnHeadY + ry;
4683: int bx = prnM11 * px + prnM12 * py + prnM13;
4684: int by = prnM21 * px + prnM22 * py + prnM23;
4685: if (0 <= bx && bx < prnRotatedWidthDot &&
4686: 0 <= by && by < prnRotatedHeightDot) {
4687: prnBitmap[bx + prnRotatedWidthDot * by] &= (byte) prnCurrentColor;
4688: }
4689: }
4690:
4691:
4692:
4693:
4694:
4695: public static boolean prnSave () {
4696:
4697:
4698:
4699:
4700: int index = prnSaveName.lastIndexOf ('.');
4701: if (index < 0) {
4702: prnSaveName += ".png";
4703: index = prnSaveName.lastIndexOf ('.');
4704: }
4705: String full = prnSavePath + File.separator + prnSaveName;
4706: File imageFile = new File (full);
4707: if (imageFile.isFile ()) {
4708:
4709:
4710:
4711:
4712:
4713: if (!imageFile.canWrite ()) {
4714: JOptionPane.showMessageDialog (
4715: null,
4716: full + (Multilingual.mlnJapanese ?
4717: "\nは既に存在します。上書きできません。" :
4718: "\nalreay exists. You cannot overwrite it."));
4719: return false;
4720: }
4721:
4722: if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog (
4723: null,
4724: full + (Multilingual.mlnJapanese ?
4725: "\nは既に存在します。上書きしますか?" :
4726: "\nalreay exists. Do you want to overwrite it?"),
4727: Multilingual.mlnJapanese ? "ファイルの上書きの確認" : "Confirmation of overwriting file",
4728: JOptionPane.YES_NO_OPTION,
4729: JOptionPane.PLAIN_MESSAGE)) {
4730: return false;
4731: }
4732: }
4733: for (Iterator<ImageWriter> iterator = ImageIO.getImageWritersBySuffix (prnSaveName.substring (index + 1));
4734:
4735: iterator.hasNext (); ) {
4736: ImageWriter imageWriter = iterator.next ();
4737: ImageWriteParam imageWriteParam = imageWriter.getDefaultWriteParam ();
4738: if (false) {
4739: if (imageWriteParam.canWriteCompressed ()) {
4740: imageWriteParam.setCompressionMode (ImageWriteParam.MODE_EXPLICIT);
4741: imageWriteParam.setCompressionQuality (0.75F);
4742: }
4743: }
4744: IIOMetadata imageMetadata = imageWriter.getDefaultImageMetadata (
4745: ImageTypeSpecifier.createFromBufferedImageType (prnImage.getType ()),
4746: imageWriteParam);
4747: if (imageMetadata.isStandardMetadataFormatSupported ()) {
4748:
4749:
4750:
4751:
4752:
4753:
4754: IIOMetadataNode rootNode = new IIOMetadataNode ("javax_imageio_1.0");
4755: IIOMetadataNode dimensionNode = new IIOMetadataNode ("Dimension");
4756: IIOMetadataNode horizontalPixelSizeNode = new IIOMetadataNode("HorizontalPixelSize");
4757: IIOMetadataNode verticalPixelSizeNode = new IIOMetadataNode ("VerticalPixelSize");
4758: horizontalPixelSizeNode.setAttribute ("value", String.valueOf (360.0 / 25.4));
4759: verticalPixelSizeNode.setAttribute ("value", String.valueOf (360.0 / 25.4));
4760: dimensionNode.appendChild (horizontalPixelSizeNode);
4761: dimensionNode.appendChild (verticalPixelSizeNode);
4762: rootNode.appendChild (dimensionNode);
4763: try {
4764: imageMetadata.mergeTree ("javax_imageio_1.0", rootNode);
4765: } catch (IIOInvalidTreeException iioite) {
4766: continue;
4767: }
4768: imageFile.delete ();
4769: try (ImageOutputStream imageOutputStream = ImageIO.createImageOutputStream (imageFile)) {
4770: imageWriter.setOutput (imageOutputStream);
4771: imageWriter.write (imageMetadata, new IIOImage (prnImage, null, imageMetadata), imageWriteParam);
4772: } catch (IOException ioe) {
4773: continue;
4774: }
4775: return true;
4776: }
4777: }
4778: JOptionPane.showMessageDialog (
4779: null,
4780: full + (Multilingual.mlnJapanese ?
4781: "\nを更新できませんでした。" :
4782: "\nwas not updated")
4783: );
4784: return false;
4785: }
4786:
4787:
4788:
4789: }
4790:
4791:
4792: