I would like the GUI separated from the Scanning functionality. So that the JSane_Scan_Dialog would be a JSane_Options_Dialog in fact, that would no longer will own or return a _frame, but just the options that the enabled application can then use for scanning and persisting (the options, i mean).
Is there a possibility to suggest/contribute?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I welcome suggestions, comments and contributions.
I'm a little strapped for time at the moment, but if you have the time to write such a class, I would be wiling to view your contribution and add it to the source, if found useful.
Would you have a [g|s]etOptions() which take / return JSane_Base_Option_Type_Discriptor [] options?
If so you might need to update JSane_Device to get / set the options.
How is your project going?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What I am trying now: I've created the new class <JSane_Options_Dialog> (has "Ok" instead of "Scan") and moved the part with all the widgets to the also new class <JSane_Option_Panel>. JSane_Options_Dialog delivers a List of Options, JSane_Base_Option_Type_Descriptor objects. I also created a Helper to convert the List of Options into a properties Object so that my applications can persist the options without having to know about the descriptor classes itself.
That's where I am puzzling at the moment. The JSane_Base_Option_Type_Descriptor.getName() method seems to return empty Strings for some Options on my scanner (e.g. "mode"). "getTitle()" delivers a string, but I assume this is a matter of internationalization. Do you think that is device specific or should I really use getTitle() for persisting options?
Another question: Do you know a List of mappings (including algorithm) of API geometry to common formats like "Letter", "A4" etc.? I wonder if this can be done in a generic way (in other words: Does Sane define a common way to specify the geometry values or is this device dependent?). However, given a user the possibility to chose amongst well-known paper formats is needful.
About my own project: Well, going slowly, my days are pretty much full of my "real" job. :)
Nevertheless I want do dedicate at least a few hours a week to code for this...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey, you're fast! (-:
Can you always create a class from scratch to solve problems? :)
Anyway, I included the class with some slight modifications and added a JComboBox in the options dialog. What I do not know now: My backend has the following gemoetry options:
--
Geometry:
-l 0..215.9mm (in steps of 0.0999908) [0]
Top-left x position of scan area.
-t 0..355.6mm (in steps of 0.0999908) [0]
Top-left y position of scan area.
-x 0..215.9mm (in steps of 0.0999908) [215.88]
Width of scan-area.
-y 0..355.6mm (in steps of 0.0999908) [355.567]
Height of scan-area.
--
But these options are not standardized in Sane, are they? So when I want to set the options for the scan area I cannot rely on the parameter names? At least I couldn't find a hint in the documentation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would like the GUI separated from the Scanning functionality. So that the JSane_Scan_Dialog would be a JSane_Options_Dialog in fact, that would no longer will own or return a _frame, but just the options that the enabled application can then use for scanning and persisting (the options, i mean).
Is there a possibility to suggest/contribute?
I welcome suggestions, comments and contributions.
I'm a little strapped for time at the moment, but if you have the time to write such a class, I would be wiling to view your contribution and add it to the source, if found useful.
Would you have a [g|s]etOptions() which take / return JSane_Base_Option_Type_Discriptor [] options?
If so you might need to update JSane_Device to get / set the options.
How is your project going?
Oh, my post of 2007-09-30 11:48 should be the answer to your posting.
What I am trying now: I've created the new class <JSane_Options_Dialog> (has "Ok" instead of "Scan") and moved the part with all the widgets to the also new class <JSane_Option_Panel>. JSane_Options_Dialog delivers a List of Options, JSane_Base_Option_Type_Descriptor objects. I also created a Helper to convert the List of Options into a properties Object so that my applications can persist the options without having to know about the descriptor classes itself.
That's where I am puzzling at the moment. The JSane_Base_Option_Type_Descriptor.getName() method seems to return empty Strings for some Options on my scanner (e.g. "mode"). "getTitle()" delivers a string, but I assume this is a matter of internationalization. Do you think that is device specific or should I really use getTitle() for persisting options?
Another question: Do you know a List of mappings (including algorithm) of API geometry to common formats like "Letter", "A4" etc.? I wonder if this can be done in a generic way (in other words: Does Sane define a common way to specify the geometry values or is this device dependent?). However, given a user the possibility to chose amongst well-known paper formats is needful.
About my own project: Well, going slowly, my days are pretty much full of my "real" job. :)
Nevertheless I want do dedicate at least a few hours a week to code for this...
The getName() and getTitle() retrieves the values provideded by the backend driver. So it may be worth asking on the sane forums.
As far as I can tell SANE only allows sizes to be set in millimeters. So the front end would need to do the conversion.
I came up with the following it seems to work.
package uk.org.jsane.JSane_Frontends;
import java.util.ArrayList;
import java.util.Iterator;
public class PaperSize
{
private double _width;
private double _height;
private String _name;
public PaperSize(String name, double width, double height)
{
_name = name;
if (width < height)
{
_width = width;
_height = height;
} else
{
_width = height;
_height = width;
}
}
public double bestfit(double widthToFind, double heightToFind)
{
PaperSize tmpPaper = new PaperSize("tmp", widthToFind, heightToFind);
return bestFit(tmpPaper);
}
public double bestFit(PaperSize tmpPaper)
{
return (Math.abs(_width - tmpPaper._width) * Math.abs(_height
- tmpPaper._height));
}
public String toString()
{
return _name;
}
public static void main(String args[])
{
ArrayList<PaperSize> papers = new ArrayList<PaperSize>();
papers.add(new PaperSize("ANSI-A", 215.9, 279.4));
papers.add(new PaperSize("ANSI-B", 279.4, 431.8));
papers.add(new PaperSize("ANSI-C", 431.8, 558.8));
papers.add(new PaperSize("ANSI-D", 558.8, 863.6));
papers.add(new PaperSize("ANSI-E", 863.6, 1117.6));
papers.add(new PaperSize("ARCH-A", 228.6, 304.8));
papers.add(new PaperSize("ARCH-B", 304.8, 457.2));
papers.add(new PaperSize("ARCH-C", 457.2, 609.6));
papers.add(new PaperSize("ARCH-D", 609.6, 914.4));
papers.add(new PaperSize("ARCH-E", 914.4, 1219.2));
papers.add(new PaperSize("ARCH-F", 762, 1066.8));
papers.add(new PaperSize("SUPER-B", 330.2, 482.6));
papers.add(new PaperSize("LEGAL -1", 215.9, 330.2));
papers.add(new PaperSize("LEGAL -2", 215.9, 355.6));
papers.add(new PaperSize("PHOTO - 3x5", 76.2, 127.0));
papers.add(new PaperSize("PHOTO - 4x6", 101.6, 152.4));
papers.add(new PaperSize("PHOTO - 5x7", 127.0, 177.8));
papers.add(new PaperSize("PHOTO - 8x10", 203.2, 254.0));
papers.add(new PaperSize("A0", 841, 1189));
papers.add(new PaperSize("A1", 594, 841));
papers.add(new PaperSize("A3", 297, 420));
papers.add(new PaperSize("A3-Extension", 483, 329));
papers.add(new PaperSize("A4", 210, 297));
papers.add(new PaperSize("A5", 148, 210));
papers.add(new PaperSize("A6", 105, 148));
papers.add(new PaperSize("B1(ISO)", 707, 1000));
papers.add(new PaperSize("B4(ISO)", 250, 353));
papers.add(new PaperSize("B5(ISO)", 176, 250));
papers.add(new PaperSize("B4(JIS)", 257, 364));
papers.add(new PaperSize("B5(JIS)", 182, 257));
papers.add(new PaperSize("C3", 324, 458));
papers.add(new PaperSize("C4", 229, 324));
papers.add(new PaperSize("C5", 162, 229));
papers.add(new PaperSize("C6", 114, 162));
papers.add(new PaperSize("DL", 220, 110));
papers.add(new PaperSize("F4", 330, 210));
papers.add(new PaperSize("RA2", 610, 430));
papers.add(new PaperSize("RA3", 430, 305));
papers.add(new PaperSize("RA4", 305, 215));
double widthToFind = 138;
double heightToFind = 87;
PaperSize bestpaper = papers.get(0);
double bestFit = bestpaper.bestfit(widthToFind, heightToFind);
for(Iterator<PaperSize> it = papers.iterator(); it.hasNext();)
{
PaperSize currentPaper = it.next();
double newBestFit = currentPaper.bestfit(widthToFind,heightToFind);
if (newBestFit < bestFit)
{
bestFit = newBestFit;
bestpaper = currentPaper;
}
}
System.out.print("Paper size = ");
System.out.println(bestpaper);
System.out.print("Best fit = ");
System.out.println(bestFit);
}
}
Hope it helps.
The papersizes were taken from a google.
Hey, you're fast! (-:
Can you always create a class from scratch to solve problems? :)
Anyway, I included the class with some slight modifications and added a JComboBox in the options dialog. What I do not know now: My backend has the following gemoetry options:
--
Geometry:
-l 0..215.9mm (in steps of 0.0999908) [0]
Top-left x position of scan area.
-t 0..355.6mm (in steps of 0.0999908) [0]
Top-left y position of scan area.
-x 0..215.9mm (in steps of 0.0999908) [215.88]
Width of scan-area.
-y 0..355.6mm (in steps of 0.0999908) [355.567]
Height of scan-area.
--
But these options are not standardized in Sane, are they? So when I want to set the options for the scan area I cannot rely on the parameter names? At least I couldn't find a hint in the documentation.
There doesn't seem to be a standard for defining options, so they get called diffrent things in diffrent backends.
Perhaps if I find time I will create one.