Добавлена фича конвертации в строку

This commit is contained in:
igor 2017-12-28 09:04:47 +03:00
parent c5c5d4fff5
commit 65489cd330
23 changed files with 410 additions and 229 deletions

View File

@ -62,7 +62,66 @@
<favorites_list name="JavaFxApplication" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300" />
<leaf>
<file leaf-file-name="OCIF.java" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/src/sample/OCIF.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="200">
<caret line="54" column="33" lean-forward="true" selection-start-line="54" selection-start-column="33" selection-end-line="54" selection-end-column="33" />
<folding>
<element signature="imports" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Palette.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/sample/Palette.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="525">
<caret line="40" column="43" lean-forward="false" selection-start-line="40" selection-start-column="43" selection-end-line="40" selection-end-column="43" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="Pixel.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/sample/Pixel.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="60">
<caret line="4" column="10" lean-forward="false" selection-start-line="4" selection-start-column="10" selection-end-line="4" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="ImageConverter.fxml" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="839">
<caret line="127" column="23" lean-forward="false" selection-start-line="127" selection-start-column="23" selection-end-line="127" selection-end-column="23" />
<folding />
</state>
</provider>
<provider editor-type-id="JavaFX-Scene-Builder">
<state />
</provider>
</entry>
</file>
<file leaf-file-name="Main.java" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3079">
<caret line="249" column="41" lean-forward="false" selection-start-line="249" selection-start-column="41" selection-end-line="249" selection-end-column="41" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
@ -85,6 +144,24 @@
<find>нед</find>
<find>размер</find>
<find>open</find>
<find>ocif</find>
<find>onTextFieldTextChanged</find>
<find>initi</find>
<find>OCIF6</find>
<find>OCIF5ConvertAsBraille</find>
<find>OCIF5ConvertAsSemiPixel</find>
<find>mainPane</find>
<find>play</find>
<find>playAnimation(</find>
<find>initiali</find>
<find>currentImagePath</find>
<find>loadImage</find>
<find>loadIm</find>
<find>encodingMethods</find>
<find>combo</find>
<find>результ</find>
<find>enable bra</find>
<find>scene</find>
</findStrings>
<replaceStrings>
<replace>sample</replace>
@ -106,16 +183,17 @@
<list>
<option value="$PROJECT_DIR$/src/sample/Color.java" />
<option value="$PROJECT_DIR$/src/sample/Pixel.java" />
<option value="$PROJECT_DIR$/src/sample/Palette.java" />
<option value="$PROJECT_DIR$/src/sample/Image.java" />
<option value="$PROJECT_DIR$/src/sample/OCIF.java" />
<option value="$PROJECT_DIR$/src/sample/Styles/button.css" />
<option value="$PROJECT_DIR$/src/sample/ImageConverter.fxml" />
<option value="$PROJECT_DIR$/src/sample/Main.java" />
<option value="$PROJECT_DIR$/src/sample/Palette.java" />
</list>
</option>
</component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds">
<component name="ProjectFrameBounds" extendedState="6">
<option name="y" value="23" />
<option name="width" value="1920" />
<option name="height" value="974" />
@ -139,6 +217,8 @@
</navigator>
<panes>
<pane id="PackagesPane" />
<pane id="Scope" />
<pane id="Scratches" />
<pane id="ProjectPane">
<subPane>
<expand>
@ -157,12 +237,17 @@
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="sample" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="ImageConverter" type="b2602c69:ProjectViewProjectNode" />
<item name="ImageConverter" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="sample" type="462c0819:PsiDirectoryNode" />
<item name="Styles" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="Scope" />
<pane id="Scratches" />
</panes>
</component>
<component name="PropertiesComponent">
@ -177,10 +262,14 @@
<property name="dynamic.classpath" value="false" />
<property name="MemberChooser.copyJavadoc" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
<property name="settings.editor.selected.configurable" value="editor.preferences.appearance" />
<property name="project.structure.last.edited" value="Artifacts" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.2" />
<property name="GenerateAntBuildDialog.enableUiFormCompile" value="true" />
<property name="GenerateAntBuildDialog.forceTargetJdk" value="true" />
<property name="GenerateAntBuildDialog.backupFiles" value="true" />
<property name="GenerateAntBuildDialog.outputFileNameProperty" value="imageconverter" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
@ -436,14 +525,16 @@
<option name="totallyTimeSpent" value="1302000" />
</component>
<component name="ToolWindowManager">
<frame x="0" y="23" width="1920" height="974" extended-state="0" />
<frame x="0" y="23" width="1920" height="973" extended-state="6" />
<editor active="true" />
<layout>
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.16302083" sideWeight="0.6703755" order="0" side_tool="false" content_ui="combo" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.14270833" sideWeight="0.6703755" order="0" side_tool="false" content_ui="combo" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3296582" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
<window_info id="Palette&#9;" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.17472528" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.17425083" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="false" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
@ -463,7 +554,6 @@
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="11" side_tool="false" content_ui="tabs" />
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.3296582" sideWeight="0.5" order="14" side_tool="false" content_ui="tabs" />
<window_info id="Image Layers" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
@ -492,20 +582,6 @@
<option name="FILTER_TARGETS" value="false" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="510">
<caret line="49" column="9" lean-forward="false" selection-start-line="49" selection-start-column="9" selection-end-line="49" selection-end-column="9" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/Pixel.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
@ -526,6 +602,7 @@
<caret line="137" column="1" lean-forward="false" selection-start-line="137" selection-start-column="1" selection-end-line="137" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>
@ -561,10 +638,6 @@
<caret line="143" column="46" lean-forward="false" selection-start-line="143" selection-start-column="46" selection-end-line="143" selection-end-column="46" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
</folding>
</state>
</provider>
@ -589,6 +662,7 @@
<caret line="113" column="14" lean-forward="false" selection-start-line="113" selection-start-column="14" selection-end-line="113" selection-end-column="14" />
<folding>
<element signature="imports" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>
@ -624,10 +698,6 @@
<caret line="143" column="46" lean-forward="false" selection-start-line="143" selection-start-column="46" selection-end-line="143" selection-end-column="46" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
</folding>
</state>
</provider>
@ -652,6 +722,7 @@
<caret line="113" column="14" lean-forward="false" selection-start-line="113" selection-start-column="14" selection-end-line="113" selection-end-column="14" />
<folding>
<element signature="imports" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>
@ -687,10 +758,6 @@
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
</folding>
</state>
</provider>
@ -715,6 +782,7 @@
<caret line="129" column="28" lean-forward="true" selection-start-line="129" selection-start-column="28" selection-end-line="129" selection-end-column="28" />
<folding>
<element signature="imports" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>
@ -750,10 +818,6 @@
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
</folding>
</state>
</provider>
@ -778,6 +842,7 @@
<caret line="10" column="47" lean-forward="false" selection-start-line="10" selection-start-column="24" selection-end-line="10" selection-end-column="47" />
<folding>
<element signature="imports" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>
@ -802,10 +867,6 @@
<caret line="8" column="0" lean-forward="false" selection-start-line="8" selection-start-column="0" selection-end-line="8" selection-end-column="0" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
</folding>
</state>
</provider>
@ -815,13 +876,6 @@
<entry file="file://$PROJECT_DIR$/src/sample/Controller.java" />
<entry file="file://$PROJECT_DIR$/src/sample/sample.fxml" />
<entry file="file://$PROJECT_DIR$/src/sample/test.java" />
<entry file="file://$PROJECT_DIR$/src/sample/Pixel.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="15" column="1" lean-forward="false" selection-start-line="15" selection-start-column="1" selection-end-line="15" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="jar:///Library/Java/JavaVirtualMachines/jdk1.8.0_111.jdk/Contents/Home/javafx-src.zip!/com/sun/javafx/event/EventHandlerManager.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="3105">
@ -839,31 +893,35 @@
<state />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/Image.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="155">
<caret line="94" column="0" lean-forward="true" selection-start-line="94" selection-start-column="0" selection-end-line="94" selection-end-column="0" />
</state>
</provider>
</entry>
<entry file="file://$USER_HOME$/Desktop/IMG_2279.JPG" />
<entry file="file://$PROJECT_DIR$/src/sample/Color.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="7">
<state relative-caret-position="-158">
<caret line="3" column="13" lean-forward="false" selection-start-line="3" selection-start-column="13" selection-end-line="3" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/Palette.java">
<entry file="file://$PROJECT_DIR$/src/sample/Image.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="90">
<caret line="6" column="37" lean-forward="false" selection-start-line="6" selection-start-column="22" selection-end-line="6" selection-end-column="37" />
<state relative-caret-position="219">
<caret line="61" column="48" lean-forward="false" selection-start-line="61" selection-start-column="39" selection-end-line="61" selection-end-column="48" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/Styles/button.css">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="315">
<caret line="21" column="1" lean-forward="true" selection-start-line="21" selection-start-column="1" selection-end-line="21" selection-end-column="1" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/ImageConverter.fxml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="318">
<caret line="95" column="49" lean-forward="false" selection-start-line="95" selection-start-column="49" selection-end-line="95" selection-end-column="49" />
<state relative-caret-position="839">
<caret line="127" column="23" lean-forward="false" selection-start-line="127" selection-start-column="23" selection-end-line="127" selection-end-column="23" />
<folding />
</state>
</provider>
@ -871,27 +929,39 @@
<state />
</provider>
</entry>
<entry file="file://$USER_HOME$/Desktop/IMG_2279.JPG" />
<entry file="file://$PROJECT_DIR$/src/sample/OCIF.java">
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="17" column="37" lean-forward="false" selection-start-line="17" selection-start-column="37" selection-end-line="17" selection-end-column="37" />
<state relative-caret-position="3079">
<caret line="249" column="41" lean-forward="false" selection-start-line="249" selection-start-column="41" selection-end-line="249" selection-end-column="41" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/Main.java">
<entry file="file://$PROJECT_DIR$/src/sample/Pixel.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="375">
<caret line="200" column="69" lean-forward="false" selection-start-line="200" selection-start-column="61" selection-end-line="200" selection-end-column="69" />
<state relative-caret-position="60">
<caret line="4" column="10" lean-forward="false" selection-start-line="4" selection-start-column="10" selection-end-line="4" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/Palette.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="525">
<caret line="40" column="43" lean-forward="false" selection-start-line="40" selection-start-column="43" selection-end-line="40" selection-end-column="43" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/src/sample/OCIF.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="200">
<caret line="54" column="33" lean-forward="true" selection-start-line="54" selection-start-column="33" selection-end-line="54" selection-end-column="33" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#3373#3819#0" expanded="true" />
<element signature="e#3818#3819#0" expanded="true" />
<element signature="e#4074#4463#0" expanded="true" />
<element signature="e#4462#4463#0" expanded="true" />
<marker date="1514437009000" expanded="true" signature="4160:5213" ph="..." />
</folding>
</state>
</provider>

View File

@ -29,15 +29,15 @@
<children>
<ImageView fx:id="imageView" fitHeight="489.0" fitWidth="840.0" nodeOrientation="INHERIT" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<image>
<Image url="@Resources/Background.jpg" />
<Image url="@Resources/Background.png" />
</image>
<effect>
<DropShadow color="#000000a0" height="34.83" offsetY="4.0" radius="19.189999999999998" width="43.93" />
<DropShadow color="#000000a0" height="41.655" offsetY="4.0" radius="20.896250000000002" width="43.93" />
</effect>
</ImageView>
</children>
</GridPane>
<GridPane fx:id="dragDropAnimationGridPane" opacity="0.0" prefHeight="489.0" prefWidth="840.0">
<GridPane fx:id="hintsGridPane" onDragEntered="#onHintsGridPaneDragEntered" onDragExited="#onHintsGridPaneDragExited" onMousePressed="#onHintsGridPaneDragMouseClicked" opacity="0.0" prefHeight="489.0" prefWidth="840.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
@ -46,17 +46,41 @@
</rowConstraints>
<children>
<Rectangle fx:id="dragFilesRectangle" fill="#000000d0" height="489.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="840.0" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" GridPane.valignment="TOP" GridPane.vgrow="ALWAYS" />
<ImageView fx:id="dragDropFilesImageView" fitWidth="180.0" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<image>
<Image url="@Resources/Files.png" />
</image>
</ImageView>
<GridPane fx:id="dragImageGridPane" visible="false">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fx:id="dragDropFilesImageView" fitWidth="180.0" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<image>
<Image url="@Resources/Files.png" />
</image>
</ImageView>
</children>
</GridPane>
<FlowPane fx:id="OCIFStringResultFlowPane" alignment="CENTER" orientation="VERTICAL" vgap="10.0" visible="false">
<children>
<Text fx:id="imageSizeText1" fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="OCIFString result" textAlignment="CENTER" wrappingWidth="312.90771484375">
<font>
<Font name="Arial" size="13.0" />
</font>
</Text>
<TextField fx:id="OCIFStringResultTextField" editable="false" onKeyReleased="#onTextFieldTextChanged" prefHeight="38.0" prefWidth="299.0" promptText="Ширина" styleClass="textField" stylesheets="@Styles/textField.css" text="FFAABBCCAAFFAAFFRRAAVVAAA">
<font>
<Font size="12.0" />
</font>
</TextField>
</children>
</FlowPane>
</children>
</GridPane>
<Pane fx:id="settingsPane" layoutX="594.0" prefHeight="489.0" prefWidth="246.0">
<children>
<Rectangle fill="#000000d0" height="489.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="246.0" />
<Button fx:id="openButton" layoutY="62.0" mnemonicParsing="false" onMouseClicked="#open" prefHeight="38.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Открыть">
<Button fx:id="openButton" layoutY="62.0" mnemonicParsing="false" onMouseClicked="#open" prefHeight="38.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Open">
<font>
<Font size="11.0" />
</font>
@ -71,12 +95,12 @@
<Font size="12.0" />
</font>
</TextField>
<Text fx:id="imageSizeText" fill="WHITE" layoutX="33.0" layoutY="124.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Размер для OpenComputers" textAlignment="CENTER" wrappingWidth="180.97265625">
<Text fx:id="imageSizeText" fill="WHITE" layoutX="33.0" layoutY="124.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Output size for OpenComputers" textAlignment="CENTER" wrappingWidth="180.97265625">
<font>
<Font name="Arial" size="11.0" />
</font>
</Text>
<Button fx:id="convertButton" layoutY="442.0" mnemonicParsing="false" onMouseClicked="#save" prefHeight="46.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Конвертировать">
<Button fx:id="convertButton" layoutY="442.0" mnemonicParsing="false" onMouseClicked="#save" prefHeight="46.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Convert">
<font>
<Font size="11.0" />
</font>
@ -86,32 +110,29 @@
<Font size="12.0" />
</font>
</TextField>
<CheckBox fx:id="brailleCheckBox" layoutX="12.0" layoutY="304.0" mnemonicParsing="false" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Использовать шрифт Брайля" textFill="WHITE" />
<Text fx:id="wrongSizesText" fill="WHITE" layoutX="23.0" layoutY="118.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Размер &gt; 256 поддерживается только форматом OCIF5" textAlignment="CENTER" visible="false" wrappingWidth="201.0">
<CheckBox fx:id="brailleCheckBox" layoutX="12.0" layoutY="304.0" mnemonicParsing="false" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Enable Braille font" textFill="WHITE" />
<Text fx:id="wrongSizesText" fill="WHITE" layoutY="124.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Size &gt; 255 is only supported with OCIF5 format" textAlignment="CENTER" visible="false" wrappingWidth="246.0">
<font>
<Font name="Arial" size="10.0" />
<Font name="Arial" size="11.0" />
</font>
</Text>
<CheckBox fx:id="ditheringCheckBox" layoutX="12.0" layoutY="342.0" mnemonicParsing="false" onMouseClicked="#onDitheringStateChanged" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Использовать дизеринг" textFill="WHITE" />
<Slider fx:id="ditheringSlider" layoutX="7.0" layoutY="392.0" min="1.0" prefHeight="16.0" prefWidth="232.0" showTickLabels="true" showTickMarks="true" stylesheets="@Styles/slider.css" value="100.0" />
<ComboBox fx:id="encodingMethodComboBox" layoutY="259.0" prefHeight="38.0" prefWidth="246.0" promptText="Формат" stylesheets="@Styles/comboBox.css">
<CheckBox fx:id="ditheringCheckBox" layoutX="12.0" layoutY="342.0" mnemonicParsing="false" onMouseClicked="#onDitheringStateChanged" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Enable dithering" textFill="WHITE" />
<Slider fx:id="ditheringSlider" layoutX="7.0" layoutY="392.0" minorTickCount="2" prefHeight="16.0" prefWidth="232.0" showTickLabels="true" showTickMarks="true" stylesheets="@Styles/slider.css" value="100.0" />
<ComboBox fx:id="encodingMethodComboBox" layoutY="259.0" onAction="#onTextFieldTextChanged" prefHeight="38.0" prefWidth="246.0" stylesheets="@Styles/comboBox.css">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="OCIF5" />
<String fx:value="OCIF6" />
<String fx:value="OCIFString" />
<String fx:value="OCIF5 (Multiscreen)" />
<String fx:value="OCIF6 (Optimized)" />
</FXCollections>
</items>
<value>
<String fx:value="OCIF6" />
</value>
</ComboBox>
<Text fill="WHITE" layoutX="33.0" layoutY="245.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Формат" textAlignment="CENTER" wrappingWidth="180.97265625">
<Text fill="WHITE" layoutX="33.0" layoutY="245.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Format" textAlignment="CENTER" wrappingWidth="180.97265625">
<font>
<Font name="Arial" size="11.0" />
</font>
</Text>
</children>
</Pane>
<ColorPicker editable="true" prefHeight="57.0" prefWidth="123.0" promptText="afae" />
</children>
</Pane>

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 KiB

View File

@ -6,7 +6,6 @@
-fx-border-radius: 0;
-fx-background-radius: 0;
-fx-font-family: "Graphon", Arial, sans-serif;
-fx-font-size: 10pt;
-fx-text-fill: #FFFFFF88;
}
@ -17,4 +16,10 @@
-fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.6) , 10, 0.2 , 0 , 1 );
}
.defaultButton:disabled {
-fx-background-color: #FFFFFF22;
-fx-text-fill: #FFFFFF77;
}

View File

@ -29,15 +29,15 @@
<children>
<ImageView fx:id="imageView" fitHeight="489.0" fitWidth="840.0" nodeOrientation="INHERIT" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<image>
<Image url="@Resources/Background.jpg" />
<Image url="@Resources/Background.png" />
</image>
<effect>
<DropShadow color="#000000a0" height="34.83" offsetY="4.0" radius="19.189999999999998" width="43.93" />
<DropShadow color="#000000a0" height="41.655" offsetY="4.0" radius="20.896250000000002" width="43.93" />
</effect>
</ImageView>
</children>
</GridPane>
<GridPane fx:id="dragDropAnimationGridPane" opacity="0.0" prefHeight="489.0" prefWidth="840.0">
<GridPane fx:id="hintsGridPane" onDragEntered="#onHintsGridPaneDragEntered" onDragExited="#onHintsGridPaneDragExited" onMousePressed="#onHintsGridPaneDragMouseClicked" opacity="0.0" prefHeight="489.0" prefWidth="840.0">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
@ -46,17 +46,41 @@
</rowConstraints>
<children>
<Rectangle fx:id="dragFilesRectangle" fill="#000000d0" height="489.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="840.0" GridPane.halignment="LEFT" GridPane.hgrow="ALWAYS" GridPane.valignment="TOP" GridPane.vgrow="ALWAYS" />
<ImageView fx:id="dragDropFilesImageView" fitWidth="180.0" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<image>
<Image url="@Resources/Files.png" />
</image>
</ImageView>
<GridPane fx:id="dragImageGridPane" visible="false">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" minWidth="10.0" prefWidth="100.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
</rowConstraints>
<children>
<ImageView fx:id="dragDropFilesImageView" fitWidth="180.0" pickOnBounds="true" preserveRatio="true" GridPane.halignment="CENTER" GridPane.valignment="CENTER">
<image>
<Image url="@Resources/Files.png" />
</image>
</ImageView>
</children>
</GridPane>
<FlowPane fx:id="OCIFStringResultFlowPane" alignment="CENTER" orientation="VERTICAL" vgap="10.0" visible="false">
<children>
<Text fx:id="imageSizeText1" fill="WHITE" strokeType="OUTSIDE" strokeWidth="0.0" text="OCIFString result" textAlignment="CENTER" wrappingWidth="312.90771484375">
<font>
<Font name="Arial" size="13.0" />
</font>
</Text>
<TextField fx:id="OCIFStringResultTextField" editable="false" onKeyReleased="#onTextFieldTextChanged" prefHeight="38.0" prefWidth="299.0" promptText="Ширина" styleClass="textField" stylesheets="@Styles/textField.css" text="FFAABBCCAAFFAAFFRRAAVVAAA">
<font>
<Font size="12.0" />
</font>
</TextField>
</children>
</FlowPane>
</children>
</GridPane>
<Pane fx:id="settingsPane" layoutX="594.0" prefHeight="489.0" prefWidth="246.0">
<children>
<Rectangle fill="#000000d0" height="489.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="0.0" width="246.0" />
<Button fx:id="openButton" layoutY="62.0" mnemonicParsing="false" onMouseClicked="#open" prefHeight="38.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Открыть">
<Button fx:id="openButton" layoutY="62.0" mnemonicParsing="false" onMouseClicked="#open" prefHeight="38.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Open">
<font>
<Font size="11.0" />
</font>
@ -71,12 +95,12 @@
<Font size="12.0" />
</font>
</TextField>
<Text fx:id="imageSizeText" fill="WHITE" layoutX="33.0" layoutY="124.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Размер для OpenComputers" textAlignment="CENTER" wrappingWidth="180.97265625">
<Text fx:id="imageSizeText" fill="WHITE" layoutX="33.0" layoutY="124.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Output size for OpenComputers" textAlignment="CENTER" wrappingWidth="180.97265625">
<font>
<Font name="Arial" size="11.0" />
</font>
</Text>
<Button fx:id="convertButton" layoutY="442.0" mnemonicParsing="false" onMouseClicked="#save" prefHeight="46.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Конвертировать">
<Button fx:id="convertButton" layoutY="442.0" mnemonicParsing="false" onMouseClicked="#save" prefHeight="46.0" prefWidth="246.0" styleClass="defaultButton" stylesheets="@Styles/button.css" text="Convert">
<font>
<Font size="11.0" />
</font>
@ -86,26 +110,24 @@
<Font size="12.0" />
</font>
</TextField>
<CheckBox fx:id="brailleCheckBox" layoutX="12.0" layoutY="304.0" mnemonicParsing="false" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Использовать шрифт Брайля" textFill="WHITE" />
<Text fx:id="wrongSizesText" fill="WHITE" layoutX="23.0" layoutY="118.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Размер &gt; 256 поддерживается только форматом OCIF5" textAlignment="CENTER" visible="false" wrappingWidth="201.0">
<CheckBox fx:id="brailleCheckBox" layoutX="12.0" layoutY="304.0" mnemonicParsing="false" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Enable Braille font" textFill="WHITE" />
<Text fx:id="wrongSizesText" fill="WHITE" layoutY="124.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Size &gt; 255 is only supported with OCIF5 format" textAlignment="CENTER" visible="false" wrappingWidth="246.0">
<font>
<Font name="Arial" size="10.0" />
<Font name="Arial" size="11.0" />
</font>
</Text>
<CheckBox fx:id="ditheringCheckBox" layoutX="12.0" layoutY="342.0" mnemonicParsing="false" onMouseClicked="#onDitheringStateChanged" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Использовать дизеринг" textFill="WHITE" />
<Slider fx:id="ditheringSlider" layoutX="7.0" layoutY="392.0" min="1.0" prefHeight="16.0" prefWidth="232.0" showTickLabels="true" showTickMarks="true" stylesheets="@Styles/slider.css" value="100.0" />
<ComboBox fx:id="encodingMethodComboBox" layoutY="259.0" prefHeight="38.0" prefWidth="246.0" promptText="Формат" stylesheets="@Styles/comboBox.css">
<CheckBox fx:id="ditheringCheckBox" layoutX="12.0" layoutY="342.0" mnemonicParsing="false" onMouseClicked="#onDitheringStateChanged" prefHeight="38.0" prefWidth="222.0" selected="true" styleClass="checkBox" stylesheets="@Styles/checkBox.css" text="Enable dithering" textFill="WHITE" />
<Slider fx:id="ditheringSlider" layoutX="7.0" layoutY="392.0" minorTickCount="2" prefHeight="16.0" prefWidth="232.0" showTickLabels="true" showTickMarks="true" stylesheets="@Styles/slider.css" value="100.0" />
<ComboBox fx:id="encodingMethodComboBox" layoutY="259.0" onAction="#onTextFieldTextChanged" prefHeight="38.0" prefWidth="246.0" stylesheets="@Styles/comboBox.css">
<items>
<FXCollections fx:factory="observableArrayList">
<String fx:value="OCIF5" />
<String fx:value="OCIF6" />
<String fx:value="OCIFString" />
<String fx:value="OCIF5 (Multiscreen)" />
<String fx:value="OCIF6 (Optimized)" />
</FXCollections>
</items>
<value>
<String fx:value="OCIF6" />
</value>
</ComboBox>
<Text fill="WHITE" layoutX="33.0" layoutY="245.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Формат" textAlignment="CENTER" wrappingWidth="180.97265625">
<Text fill="WHITE" layoutX="33.0" layoutY="245.0" strokeType="OUTSIDE" strokeWidth="0.0" text="Format" textAlignment="CENTER" wrappingWidth="180.97265625">
<font>
<Font name="Arial" size="11.0" />
</font>

View File

@ -10,8 +10,10 @@ import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.image.ImageView;
import javafx.scene.input.DragEvent;
import javafx.scene.input.Dragboard;
import javafx.scene.input.TransferMode;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import javafx.scene.text.Text;
@ -21,6 +23,7 @@ import javafx.util.Callback;
import javafx.util.Duration;
import java.io.File;
import java.io.IOException;
import java.util.Locale;
import java.util.regex.Pattern;
public class Main extends Application {
@ -36,19 +39,23 @@ public class Main extends Application {
public Text imageSizeText;
public Slider ditheringSlider;
public ComboBox<String> encodingMethodComboBox;
public Pane dragDropAnimationGridPane;
public GridPane imageGridPane;
public ImageView dragDropFilesImageView;
public Pane settingsPane;
public Pane mainPane;
private String currentImagePath = "sample/Resources/Background.jpg";
public GridPane hintsGridPane;
public GridPane dragImageGridPane;
public FlowPane OCIFStringResultFlowPane;
public TextField OCIFStringResultTextField;
private String currentImagePath = "sample/Resources/Background.png";
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setResizable(false);
Scene scene = new Scene(FXMLLoader.load(getClass().getResource("ImageConverter.fxml")));
primaryStage.setScene(scene);
primaryStage.setScene(new Scene(FXMLLoader.load(getClass().getResource("ImageConverter.fxml")), 840, 489));
primaryStage.show();
}
@ -61,27 +68,34 @@ public class Main extends Application {
return timeline;
}
private void playDragDropFileAnimation(boolean start, boolean moveSettingsPane, double targetOpacity, double fromScale, double toScale)
{
private void playAnimation(boolean start, double targetOpacity, double fromScale, double toScale) {
Timeline timeline = newTimeLine(
150,
new KeyValue[] {
new KeyValue(dragDropAnimationGridPane.opacityProperty(), dragDropAnimationGridPane.getOpacity()),
new KeyValue(hintsGridPane.opacityProperty(), hintsGridPane.getOpacity()),
new KeyValue(dragDropFilesImageView.fitWidthProperty(), dragDropFilesImageView.getImage().getWidth() * fromScale),
moveSettingsPane ? new KeyValue(settingsPane.layoutXProperty(), start ? mainPane.getWidth() - settingsPane.getWidth() : mainPane.getWidth()) : null
new KeyValue(settingsPane.layoutXProperty(), start ? mainPane.getWidth() - settingsPane.getWidth() : mainPane.getWidth())
},
new KeyValue[] {
new KeyValue(dragDropAnimationGridPane.opacityProperty(), targetOpacity),
new KeyValue(hintsGridPane.opacityProperty(), targetOpacity),
new KeyValue(dragDropFilesImageView.fitWidthProperty(), dragDropFilesImageView.getImage().getWidth() * toScale),
moveSettingsPane ? new KeyValue(settingsPane.layoutXProperty(), start ? mainPane.getWidth() : mainPane.getWidth() - settingsPane.getWidth()) : null
new KeyValue(settingsPane.layoutXProperty(), start ? mainPane.getWidth() : mainPane.getWidth() - settingsPane.getWidth())
}
);
timeline.play();
}
private void playAnimationStart() {
playAnimation(true, 1.0d, 0.8d, 1.0d);
}
private void playAnimationEnd() {
playAnimation(false, 0.0d, 1.0d, 0.8d);
}
public void initialize() {
// Пидорасим текст по центру комбобокса
// Центрируем хуйню самого комбобокса
encodingMethodComboBox.setButtonCell(new ListCell<String>() {
@Override
public void updateItem(String item, boolean empty) {
@ -95,7 +109,7 @@ public class Main extends Application {
}
});
// А это уже в выпадающем списке
// Центрируем хуйню в выпадающем списке комбобокса
encodingMethodComboBox.setCellFactory(new Callback<ListView<String>, ListCell<String>>() {
@Override
public ListCell<String> call(ListView<String> list) {
@ -112,25 +126,38 @@ public class Main extends Application {
}
});
//Ебучий драг-дроп
dragDropAnimationGridPane.setOnDragEntered(event -> {
if (event.getDragboard().hasFiles()) {
playDragDropFileAnimation(true, true,1.0d, 0.8d, 1.0d);
event.acceptTransferModes(TransferMode.COPY);
}
});
encodingMethodComboBox.setValue("OCIF6 (Optimized)");
}
dragDropAnimationGridPane.setOnDragExited(event -> {
playDragDropFileAnimation(false, true, 0.0d, 1.0d, 0.8d);
//Ебучий драг-дроп
public void onHintsGridPaneDragEntered(DragEvent event) {
dragImageGridPane.setVisible(true);
OCIFStringResultFlowPane.setVisible(false);
Dragboard dragboard = event.getDragboard();
if (dragboard.hasFiles()) {
File file = new File(dragboard.getFiles().get(0).getAbsolutePath());
if (file.getAbsolutePath().toLowerCase().matches("^.+\\.(png)?(jpg)?(jpeg)?$")) {
loadImage(file);
}
if (event.getDragboard().hasFiles()) {
playAnimationStart();
event.acceptTransferModes(TransferMode.COPY);
}
}
public void onHintsGridPaneDragExited(DragEvent event) {
playAnimationEnd();
Dragboard dragboard = event.getDragboard();
if (dragboard.hasFiles()) {
File file = new File(dragboard.getFiles().get(0).getAbsolutePath());
if (file.getAbsolutePath().toLowerCase().matches("^.+\\.(png)?(jpg)?(jpeg)?$")) {
loadImage(file);
}
});
}
dragImageGridPane.setVisible(false);
}
public void onHintsGridPaneDragMouseClicked() {
if (hintsGridPane.getOpacity() == 1) {
playAnimationEnd();
}
}
public static void main(String[] args) {
@ -152,21 +179,11 @@ public class Main extends Application {
}
public void onTextFieldTextChanged() {
boolean state = checkTextField(widthTextField) && checkTextField(heightTextField);
boolean state = (checkTextField(widthTextField) && checkTextField(heightTextField)) || encodingMethodComboBox.getValue().contains("OCIF5");
// convertButton.setDisable(!state);
imageSizeText.setVisible(state);
wrongSizesText.setVisible(!state);
encodingMethodComboBox.getItems().clear();
if (state) {
encodingMethodComboBox.setValue("OCIF6");
encodingMethodComboBox.getItems().add("OCIF5");
encodingMethodComboBox.getItems().add("OCIF6");
} else {
encodingMethodComboBox.setValue("OCIF5");
encodingMethodComboBox.getItems().add("OCIF5");
}
convertButton.setDisable(!state);
}
private void loadImage(File file) {
@ -206,22 +223,40 @@ public class Main extends Application {
}
public void save() throws IOException {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Сохранить файл");
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Изображение OpenComputers", "*.pic"));
File file = fileChooser.showSaveDialog(openButton.getScene().getWindow());
if (file != null) {
OCIF.convert(
currentImagePath,
file.getPath(),
Integer.parseInt(widthTextField.getText()),
Integer.parseInt(heightTextField.getText()),
encodingMethodComboBox.getValue().equals("OCIF6") ? 6 : 5,
brailleCheckBox.isSelected(),
ditheringCheckBox.isSelected(),
ditheringSlider.getValue()
if (encodingMethodComboBox.getValue().contains("OCIFString")) {
String result = OCIF.convertToString(
currentImagePath,
Integer.parseInt(widthTextField.getText()),
Integer.parseInt(heightTextField.getText()),
brailleCheckBox.isSelected(),
ditheringCheckBox.isSelected(),
ditheringSlider.getValue()
);
dragImageGridPane.setVisible(false);
OCIFStringResultFlowPane.setVisible(true);
playAnimationStart();
OCIFStringResultTextField.setText(result);
}
else {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Сохранить файл");
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Изображение OpenComputers", "*.pic"));
File file = fileChooser.showSaveDialog(openButton.getScene().getWindow());
if (file != null) {
OCIF.convert(
currentImagePath,
file.getPath(),
Integer.parseInt(widthTextField.getText()),
Integer.parseInt(heightTextField.getText()),
encodingMethodComboBox.getValue().contains("OCIF6") ? 6 : 5,
brailleCheckBox.isSelected(),
ditheringCheckBox.isSelected(),
ditheringSlider.getValue()
);
}
}
}
}

View File

@ -5,18 +5,10 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import sample.Palette;
public class OCIF {
private static void writePixelToFileAsOCIF1(FileOutputStream out, Pixel pixel) throws IOException {
// out.write((byte) pixel.background.red);
// out.write((byte) pixel.background.green);
// out.write((byte) pixel.background.blue);
// out.write((byte) pixel.foreground.red);
// out.write((byte) pixel.foreground.green);
// out.write((byte) pixel.foreground.blue);
private static void writePixelToFileAsOCIF5(FileOutputStream out, Pixel pixel) throws IOException {
out.write((byte) Palette.getClosestIndex(pixel.background));
out.write((byte) Palette.getClosestIndex(pixel.foreground));
@ -89,36 +81,7 @@ public class OCIF {
}
}
private static void OCIF1ConvertAsBraille(FileOutputStream out, sample.Image image) throws IOException {
for (int y = 0; y < image.height; y += 4) {
for (int x = 0; x < image.width; x += 2) {
writePixelToFileAsOCIF1(out, sample.Image.getBraillePixel(image, x, y));
}
}
}
private static void OCIF1ConvertAsSemiPixel(FileOutputStream out, sample.Image image) throws IOException {
for (int y = 0; y < image.height; y += 2) {
for (int x = 0; x < image.width; x++) {
writePixelToFileAsOCIF1(out, sample.Image.getSemiPixel(image, x, y));
}
}
}
public static void convert(String imagePath, String convertedImagePath, int requestedWidth, int requestedHeight, int encodingMethod, boolean convertAsBraille, boolean enableDithering, double ditheringIntensity) throws IOException {
FileOutputStream out = new FileOutputStream(convertedImagePath);
out.write("OCIF".getBytes(StandardCharsets.US_ASCII));
out.write((byte) encodingMethod);
if (encodingMethod == 5) {
out.write(integerToByteArray(requestedWidth, 2));
out.write(integerToByteArray(requestedHeight, 2));
} else {
out.write((byte) requestedWidth);
out.write((byte) requestedHeight);
}
private static sample.Image loadImage(String imagePath, int requestedWidth, int requestedHeight, boolean convertAsBraille, boolean enableDithering, double ditheringIntensity) {
sample.Image image = new sample.Image(new javafx.scene.image.Image(imagePath,
requestedWidth * (convertAsBraille ? 2 : 1),
requestedHeight * (convertAsBraille ? 4 : 2),
@ -130,16 +93,79 @@ public class OCIF {
image = sample.Image.dither(image, ditheringIntensity);
}
return image;
}
private static void appendPixel(StringBuilder result, Pixel pixel) {
result.append(String.format("%02X", Palette.getClosestIndex(pixel.background)));
result.append(String.format("%02X", Palette.getClosestIndex(pixel.foreground)));
result.append(String.format("%02X", pixel.alpha));
result.append(pixel.symbol);
}
static String convertToString(String imagePath, int requestedWidth, int requestedHeight, boolean convertAsBraille, boolean enableDithering, double ditheringIntensity) {
sample.Image image = loadImage(imagePath, requestedWidth, requestedHeight, convertAsBraille, enableDithering, ditheringIntensity);
StringBuilder result = new StringBuilder();
result.append(String.format("%02X", requestedWidth));
result.append(String.format("%02X", requestedHeight));
if (convertAsBraille) {
for (int y = 0; y < image.height; y += 4) {
for (int x = 0; x < image.width; x += 2) {
appendPixel(result, sample.Image.getBraillePixel(image, x, y));
}
}
}
else {
for (int y = 0; y < image.height; y += 2) {
for (int x = 0; x < image.width; x += 1) {
appendPixel(result, sample.Image.getSemiPixel(image, x, y));
}
}
}
return result.toString();
}
static void convert(String imagePath, String convertedImagePath, int requestedWidth, int requestedHeight, int encodingMethod, boolean convertAsBraille, boolean enableDithering, double ditheringIntensity) throws IOException {
FileOutputStream out = new FileOutputStream(convertedImagePath);
out.write("OCIF".getBytes(StandardCharsets.US_ASCII));
out.write((byte) encodingMethod);
if (encodingMethod == 5) {
out.write(integerToByteArray(requestedWidth, 2));
out.write(integerToByteArray(requestedHeight, 2));
}
else{
out.write((byte) requestedWidth);
out.write((byte) requestedHeight);
}
sample.Image image = loadImage(imagePath, requestedWidth, requestedHeight, convertAsBraille, enableDithering, ditheringIntensity);
if (convertAsBraille) {
if (encodingMethod == 5) {
OCIF1ConvertAsBraille(out, image);
} else {
for (int y = 0; y < image.height; y += 4) {
for (int x = 0; x < image.width; x += 2) {
writePixelToFileAsOCIF5(out, sample.Image.getBraillePixel(image, x, y));
}
}
}
else {
writeGroupedImage(out, sample.Image.groupAsBraille(image));
}
} else {
}
else {
if (encodingMethod == 5) {
OCIF1ConvertAsSemiPixel(out, image);
} else {
for (int y = 0; y < image.height; y += 2) {
for (int x = 0; x < image.width; x += 1) {
writePixelToFileAsOCIF5(out, sample.Image.getSemiPixel(image, x, y));
}
}
}
else {
writeGroupedImage(out, sample.Image.groupAsSemiPixel(image));
}
}

View File

@ -4,14 +4,12 @@ package sample;
public class Palette {
private static int[] palette = { 0x000000, 0x000040, 0x000080, 0x0000BF, 0x0000FF, 0x002400, 0x002440, 0x002480, 0x0024BF, 0x0024FF, 0x004900, 0x004940, 0x004980, 0x0049BF, 0x0049FF, 0x006D00, 0x006D40, 0x006D80, 0x006DBF, 0x006DFF, 0x009200, 0x009240, 0x009280, 0x0092BF, 0x0092FF, 0x00B600, 0x00B640, 0x00B680, 0x00B6BF, 0x00B6FF, 0x00DB00, 0x00DB40, 0x00DB80, 0x00DBBF, 0x00DBFF, 0x00FF00, 0x00FF40, 0x00FF80, 0x00FFBF, 0x00FFFF, 0x0F0F0F, 0x1E1E1E, 0x2D2D2D, 0x330000, 0x330040, 0x330080, 0x3300BF, 0x3300FF, 0x332400, 0x332440, 0x332480, 0x3324BF, 0x3324FF, 0x334900, 0x334940, 0x334980, 0x3349BF, 0x3349FF, 0x336D00, 0x336D40, 0x336D80, 0x336DBF, 0x336DFF, 0x339200, 0x339240, 0x339280, 0x3392BF, 0x3392FF, 0x33B600, 0x33B640, 0x33B680, 0x33B6BF, 0x33B6FF, 0x33DB00, 0x33DB40, 0x33DB80, 0x33DBBF, 0x33DBFF, 0x33FF00, 0x33FF40, 0x33FF80, 0x33FFBF, 0x33FFFF, 0x3C3C3C, 0x4B4B4B, 0x5A5A5A, 0x660000, 0x660040, 0x660080, 0x6600BF, 0x6600FF, 0x662400, 0x662440, 0x662480, 0x6624BF, 0x6624FF, 0x664900, 0x664940, 0x664980, 0x6649BF, 0x6649FF, 0x666D00, 0x666D40, 0x666D80, 0x666DBF, 0x666DFF, 0x669200, 0x669240, 0x669280, 0x6692BF, 0x6692FF, 0x66B600, 0x66B640, 0x66B680, 0x66B6BF, 0x66B6FF, 0x66DB00, 0x66DB40, 0x66DB80, 0x66DBBF, 0x66DBFF, 0x66FF00, 0x66FF40, 0x66FF80, 0x66FFBF, 0x66FFFF, 0x696969, 0x787878, 0x878787, 0x969696, 0x990000, 0x990040, 0x990080, 0x9900BF, 0x9900FF, 0x992400, 0x992440, 0x992480, 0x9924BF, 0x9924FF, 0x994900, 0x994940, 0x994980, 0x9949BF, 0x9949FF, 0x996D00, 0x996D40, 0x996D80, 0x996DBF, 0x996DFF, 0x999200, 0x999240, 0x999280, 0x9992BF, 0x9992FF, 0x99B600, 0x99B640, 0x99B680, 0x99B6BF, 0x99B6FF, 0x99DB00, 0x99DB40, 0x99DB80, 0x99DBBF, 0x99DBFF, 0x99FF00, 0x99FF40, 0x99FF80, 0x99FFBF, 0x99FFFF, 0xA5A5A5, 0xB4B4B4, 0xC3C3C3, 0xCC0000, 0xCC0040, 0xCC0080, 0xCC00BF, 0xCC00FF, 0xCC2400, 0xCC2440, 0xCC2480, 0xCC24BF, 0xCC24FF, 0xCC4900, 0xCC4940, 0xCC4980, 0xCC49BF, 0xCC49FF, 0xCC6D00, 0xCC6D40, 0xCC6D80, 0xCC6DBF, 0xCC6DFF, 0xCC9200, 0xCC9240, 0xCC9280, 0xCC92BF, 0xCC92FF, 0xCCB600, 0xCCB640, 0xCCB680, 0xCCB6BF, 0xCCB6FF, 0xCCDB00, 0xCCDB40, 0xCCDB80, 0xCCDBBF, 0xCCDBFF, 0xCCFF00, 0xCCFF40, 0xCCFF80, 0xCCFFBF, 0xCCFFFF, 0xD2D2D2, 0xE1E1E1, 0xF0F0F0, 0xFF0000, 0xFF0040, 0xFF0080, 0xFF00BF, 0xFF00FF, 0xFF2400, 0xFF2440, 0xFF2480, 0xFF24BF, 0xFF24FF, 0xFF4900, 0xFF4940, 0xFF4980, 0xFF49BF, 0xFF49FF, 0xFF6D00, 0xFF6D40, 0xFF6D80, 0xFF6DBF, 0xFF6DFF, 0xFF9200, 0xFF9240, 0xFF9280, 0xFF92BF, 0xFF92FF, 0xFFB600, 0xFFB640, 0xFFB680, 0xFFB6BF, 0xFFB6FF, 0xFFDB00, 0xFFDB40, 0xFFDB80, 0xFFDBBF, 0xFFDBFF, 0xFFFF00, 0xFFFF40, 0xFFFF80, 0xFFFFBF, 0xFFFFFF };
public static int getClosestIndex(Color color)
{
public static int getClosestIndex(Color color) {
int closestIndex = 0;
double delta, closestDelta = 999999999.0d;
Color paletteColor;
for (int i = 0; i < palette.length; i++)
{
for (int i = 0; i < palette.length; i++) {
paletteColor = new Color(
0x0,
palette[i] >> 16,
@ -23,8 +21,7 @@ public class Palette {
Math.pow((double) (paletteColor.green - color.green), 2) +
Math.pow((double) (paletteColor.blue - color.blue), 2);
if (delta < closestDelta)
{
if (delta < closestDelta) {
closestDelta = delta;
closestIndex = i;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 356 KiB

View File

@ -6,7 +6,6 @@
-fx-border-radius: 0;
-fx-background-radius: 0;
-fx-font-family: "Graphon", Arial, sans-serif;
-fx-font-size: 10pt;
-fx-text-fill: #FFFFFF88;
}
@ -17,4 +16,10 @@
-fx-effect: dropshadow( three-pass-box , rgba(255,255,255,0.6) , 10, 0.2 , 0 , 1 );
}
.defaultButton:disabled {
-fx-background-color: #FFFFFF22;
-fx-text-fill: #FFFFFF77;
}