|
Posted by Samanyu
at Jul 23, 2024, 8:47:04 AM
|
Re: Plugin Development Issue
Update: I downloaded the jar from the example in the guide, decompiled the java class copied and pasted the same code, and exported it as the jar in the plugins folder, but it still didn't work. Could you please help me identify the issue?
package com.eteks.test;
import java.awt.Component; import java.util.Iterator;
import javax.swing.JOptionPane;
import com.eteks.sweethome3d.model.PieceOfFurniture; import com.eteks.sweethome3d.plugin.Plugin; import com.eteks.sweethome3d.plugin.PluginAction;
public class VolumePlugin extends Plugin { public PluginAction[] getActions() { return new PluginAction[]{new VolumePlugin.VolumeAction()}; }
public class VolumeAction extends PluginAction { public VolumeAction() { this.putPropertyValue(Property.NAME, "Compute volume"); this.putPropertyValue(Property.MENU, "Tools"); this.setEnabled(true); }
public void execute() { float volumeInCm3 = 0.0F; Iterator var3 = VolumePlugin.this.getHome().getFurniture().iterator();
while(var3.hasNext()) { PieceOfFurniture piece = (PieceOfFurniture)var3.next(); if (piece.isMovable()) { volumeInCm3 += piece.getWidth() * piece.getDepth() * piece.getHeight(); } }
String message = String.format("The maximum volume of the movable furniture in home is %.2f m³.", volumeInCm3 / 1000000.0F); JOptionPane.showMessageDialog((Component)null, message); } } }
|