class WinXP {
private static boolean isXP;
private static Map<Integer, Integer> faultyXPCodes = new HashMap<>();
static {
String os = System.getProperty("os.name").toLowerCase();
isXP = os.startsWith("windows") && os.contains("xp");
faultyXPCodes.put(91 , 0x1A); // [
faultyXPCodes.put(93 , 0x1B); // ]
faultyXPCodes.put(92 , 0x2B); // \
faultyXPCodes.put(59 , 0x27); // ;
faultyXPCodes.put(222, 0x28); // '
faultyXPCodes.put(44 , 0x33); // ,
faultyXPCodes.put(46 , 0x34); // .
faultyXPCodes.put(47 , 0x35); // /
}
private static boolean isFaulty(int code) {
return isXP && faultyXPCodes.containsKey(code);
}
private static WinUser.INPUT PrepareInput(int flag, int code) {
final WinUser.INPUT input = new WinUser.INPUT();
input.type = new WinDef.DWORD(WinUser.INPUT.INPUT_KEYBOARD);
input.input.setType("ki");
input.input.ki.wScan = new WinDef.WORD(0x0);
input.input.ki.time = new WinDef.DWORD(0x0);
input.input.ki.dwFlags = new WinDef.DWORD(flag | 0x8);
input.input.ki.dwExtraInfo = new BaseTSD.ULONG_PTR(0x0);
input.input.ki.wScan = new WinDef.WORD(faultyXPCodes.get(code));
return input;
}
private static void SendInput(WinUser.INPUT input) {
User32.INSTANCE.SendInput(
new WinDef.DWORD(1),
(WinUser.INPUT[]) input.toArray(1),
input.size()
);
}
private static void Press(int code) {
SendInput(PrepareInput(0x0, code));
}
private static void Release(int code) {
SendInput(PrepareInput(0x2, code));
}
}
public static long getFreeSpace(String path) {
File folder = new File(path);
return folder.getFreeSpace();
}
ArrayList<String> list = new ArrayList<>();
ArrayList list = new ArrayList()
ArrayList<Object> list = new ArrayList<>()
public static BufferedImage[] splitToRGB(BufferedImage original) {
BufferedImage R = new BufferedImage(
original.getWidth(), original.getHeight(),
BufferedImage.TYPE_INT_RGB
);
BufferedImage G = new BufferedImage(
original.getWidth(), original.getHeight(),
BufferedImage.TYPE_INT_RGB
);
BufferedImage B = new BufferedImage(
original.getWidth(), original.getHeight(),
BufferedImage.TYPE_INT_RGB
);
for (int x = 0; x < original.getWidth(); x++)
for (int y = 0; y < original.getHeight(); y++) {
final int rgb = original.getRGB(x, y);
R.setRGB(x, y, rgb & 0xff0000);
G.setRGB(x, y, rgb & 0xff00);
B.setRGB(x, y, rgb & 0xff);
}
return new BufferedImage[]{R, G, B};
}
public static BufferedImage mergeRGB(BufferedImage R, BufferedImage G, BufferedImage B) {
BufferedImage original = new BufferedImage(
R.getWidth(), R.getHeight(),
BufferedImage.TYPE_INT_RGB
);
for (int x = 0; x < original.getWidth(); x++)
for (int y = 0; y < original.getHeight(); y++) {
final int rgb = R.getRGB(x, y) | G.getRGB(x, y) | B.getRGB(x, y);
original.setRGB(x, y, rgb);
}
return original;
}
Почему на Java видны так сильно пиксели? А при добавлении фотошопа нет. И как добиться сглаженного и красивого текст в java?Потому что по-умолчанию drawString не использует сглаживание. Как его включить, можно посмотреть в официальной документации
/**
* Created by Labunsky on 24.03.2017.
*/
public class MultiListEntry<S, C> {
private MultiListEntry<S, C> nextStudentEntry = null;
private MultiListEntry<S, C> nextCourseEntry = null;
private S student;
private C course;
MultiListEntry(S student, C course) {
this.student = student;
this.course = course;
}
public S getStudent() {
return student;
}
public C getCourse() {
return course;
}
public void setNextStudentEntry(MultiListEntry<S, C> next) {
nextStudentEntry = next;
}
public void setNextCourseEntry(MultiListEntry<S, C> next) {
this.nextCourseEntry = next;
}
public MultiListEntry<S, C> getNextStudentEntry() {
return nextStudentEntry;
}
public MultiListEntry<S, C> getNextCourseEntry() {
return nextCourseEntry;
}
}
/**
* Created by Labunsky on 24.03.2017.
*/
public class MultiList<S, C> {
private Map<S, MultiListEntry<S, C>> studentsIndex = new HashMap<>();
private Map<C, MultiListEntry<S, C>> coursesIndex = new HashMap<>();
public void add(S student, C course) {
MultiListEntry<S, C> newEntry = new MultiListEntry<>(student, course);
MultiListEntry<S, C> lastEntry;
if (studentsIndex.containsKey(student)) {
lastEntry = studentsIndex.get(student);
while (lastEntry.getNextStudentEntry() != null)
lastEntry = lastEntry.getNextStudentEntry();
lastEntry.setNextStudentEntry(newEntry);
} studentsIndex.put(student, newEntry);
if (coursesIndex.containsKey(course)) {
lastEntry = coursesIndex.get(course);
while (lastEntry.getNextCourseEntry() != null)
lastEntry = lastEntry.getNextCourseEntry();
lastEntry.setNextCourseEntry(newEntry);
} else coursesIndex.put(course, newEntry);
}
public MultiListEntry<S, C> getStudentEntries(S student) {
return studentsIndex.get(student);
}
public MultiListEntry<S, C> getCourseEntries(C course) {
return coursesIndex.get(course);
}
}
while (b) {
out.writeUTF(line); // отсылаем введенную строку текста серверу.
out.flush(); // заставляем поток закончить передачу данных.
line = in.readUTF(); // ждем пока сервер отошлет строку текста.
tvOut.setText(line);
b=false;
}