Plugins adaptados para a nova versão

This commit is contained in:
GustavoHMDS committed 2026-09-30 13:58:35 -03:00
1 parent 9fb4952f32
commit fa696194aa
42 files changed
+274 -106

No files matched your search

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../pitiupi/dist/pitiupi.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -5,6 +5,8 @@
*/
package pitiupi.screenCast.GUI;
import pitiupi.control.ConnectionManager;
import pitiupi.control.GuiManager;
import pitiupi.screenCast.control.AlarmClock;
import pitiupi.screenCast.control.ImageTransformation;
import pitiupi.screenCast.control.ScreenShot;
@@ -38,10 +40,13 @@ public class ScreenCastWindow extends javax.swing.JFrame {
public final static int TIME = 1000;
private float compressRatio;
private final MainWindow mainWindow;
private final ConnectionManager connectionManager;
private final GuiManager guiManager;
public ScreenCastWindow(ConnectionManager connectionManager, GuiManager guiManager) {
this.connectionManager = connectionManager;
this.guiManager = guiManager;
public ScreenCastWindow(MainWindow mainWindow) {
this.mainWindow = mainWindow;
this.compressRatio = 0.5f;
this.initComponents();
}
@@ -91,19 +96,12 @@ public class ScreenCastWindow extends javax.swing.JFrame {
BufferedImage image = ScreenShot.takeAShot();
BufferedImage rescaled = ImageTransformation.resize(image, 1024, 768);
byte[] byteImage = ImageTransformation.compress(rescaled, compressRatio);
ScreenCastMessage message = new ScreenCastMessage(this.mainWindow.getUserName(), byteImage);
msg = message.toByteArray();
ScreenCastMessage message = new ScreenCastMessage(this.connectionManager.getUserName(), byteImage);
if (!connectionManager.sendUdpMulticast(message)) this.compressRatio -= 0.1f;
} catch (AWTException | IOException ex) {
Logger.getLogger(AlarmClock.class.getName()).log(Level.SEVERE, null, ex);
}
if (msg != null) {
try {
this.mainWindow.getSocketUDP().sendMulticast(msg);
} catch (IOException ex) {
System.out.println(ex.toString());
this.compressRatio -= 0.1f;
}
}
}
public void receiveScreenCastMessage(ScreenCastMessage message) {
@@ -8,6 +8,8 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import pitiupi.GUI.MainWindow;
import pitiupi.control.ConnectionManager;
import pitiupi.control.GuiManager;
import pitiupi.net.Message;
import pitiupi.plugin.Plugin;
import pitiupi.screenCast.GUI.ScreenCastMenu;
@@ -21,7 +23,6 @@ import pitiupi.screenCast.net.ScreenCastMessage;
public class ScreenCastPlugin implements Plugin {
private ScreenCastWindow screenCastWindow;
private MainWindow mainWindow;
@Override
public String getName() {
@@ -39,10 +40,14 @@ public class ScreenCastPlugin implements Plugin {
}
@Override
public void createPlugin(MainWindow mainWindow) {
this.mainWindow = mainWindow;
this.screenCastWindow = new ScreenCastWindow(mainWindow);
this.mainWindow.addMenu(new ScreenCastMenu(screenCastWindow));
public String getIdentifier() {
return "Pitiupi.ScreenCast.Example";
}
@Override
public void createPlugin(ConnectionManager connectionManager, GuiManager guiManager) {
this.screenCastWindow = new ScreenCastWindow(connectionManager, guiManager);
guiManager.addMenu(new ScreenCastMenu(screenCastWindow));
}
@Override
@@ -54,9 +59,7 @@ public class ScreenCastPlugin implements Plugin {
if (ois.readObject() instanceof ScreenCastMessage msg) {
this.screenCastWindow.receiveScreenCastMessage(msg);
}
} catch (IOException ex) {
System.out.println(ex.toString());
} catch (ClassNotFoundException ex) {
} catch (IOException | ClassNotFoundException ex) {
System.out.println(ex.toString());
}
}