當前位置: 首頁>>代碼示例>>Java>>正文


Java DragEvent類代碼示例

本文整理匯總了Java中javafx.scene.input.DragEvent的典型用法代碼示例。如果您正苦於以下問題:Java DragEvent類的具體用法?Java DragEvent怎麽用?Java DragEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DragEvent類屬於javafx.scene.input包,在下文中一共展示了DragEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkPlaceableTile

import javafx.scene.input.DragEvent; //導入依賴的package包/類
private boolean checkPlaceableTile (DragEvent e) {
    double halfHeight =
            (0.5) * myScale
                    .scale((mySprite.getBounds().getBottom() - mySprite.getBounds().getTop()));
    double halfWidth =
            (0.5) * myScale
                    .scale((mySprite.getBounds().getRight() - mySprite.getBounds().getLeft()));
    for (int r =
            (int) ((e.getY() - halfHeight) / levelView.getGrids()
                    .getCurrentBlockSize()); r < (int) ((e.getY() + halfHeight) /
                                                        levelView.getGrids()
                                                                .getCurrentBlockSize()); r++) {
        for (int c =
                (int) ((e.getX() - halfWidth) / levelView.getGrids()
                        .getCurrentBlockSize()); c < (int) ((e.getX() + halfWidth) / levelView
                                .getGrids().getCurrentBlockSize()); c++) {
            if (levelView.getLevel().getPlaceableTileManager().getPlaceableMap()
                    .getBitMap()[r][c]) {
                return false;
            }
        }
    }
    return true;
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:25,代碼來源:OnScreenSprite.java

示例2: checkPlaceableTile

import javafx.scene.input.DragEvent; //導入依賴的package包/類
private boolean checkPlaceableTile (DragEvent e) {
    double halfHeight =
            (0.5) * myController.getRatio()
                    .scale((getProfilable().getProfile().getImageHeight().doubleValue()));
    double halfWidth =
            (0.5) * myController.getRatio()
                    .scale((getProfilable().getProfile().getImageWidth().doubleValue()));
    for (int r =
            (int) ((e.getY() - halfHeight) /
                   myController.getRatio().scale(50)); r < (int) ((e.getY() + halfHeight) /
                                                                  myController.getRatio()
                                                                          .scale(50)); r++) {
        for (int c =
                (int) ((e.getX() - halfWidth) / myController.getRatio()
                        .scale(50)); c < (int) ((e.getX() + halfWidth) /
                                                myController.getRatio().scale(50)); c++) {
            if (myController.getLevel().getPlaceableTileManager().getPlaceableMap()
                    .getBitMap()[r][c]) {
                return false;
            }
        }
    }
    return true;
}
 
開發者ID:tomrom95,項目名稱:GameAuthoringEnvironment,代碼行數:25,代碼來源:DraggableSpriteCell.java

示例3: mouseDragDropped

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Handle mouse drop events
 * 
 * @param e
 */
private void mouseDragDropped(final DragEvent e) {
	final Dragboard db = e.getDragboard();
	boolean success = false;

	if (db.hasFiles()) {
		success = true;
		boolean ctrlKeyPressed = popOver.isCtrlKeyPressed();
		boolean altKeyPressed = popOver.isAltKeyPressed();
		
		popOver.notifyDragEventListener(new DropzoneDragEvent(e, ctrlKeyPressed, altKeyPressed));

	}
	e.setDropCompleted(success);
	e.consume();
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:21,代碼來源:DropzonePopOverUI.java

示例4: AddTypeCommand

import javafx.scene.input.DragEvent; //導入依賴的package包/類
public AddTypeCommand(MomentExpVBox moment, DragEvent event, Main main) {
	this.event = event;
	typeName = event.getDragboard().getRtf();
	this.momentExpBorder = moment;
	this.main = main;

	for(Type t : main.getCurrentProject().getSchemaProjet().getTypes()){
		if(t.getName().equals(typeName)){
			type = (Classe) t;
		}
		else{
			setClassByName(t);
		}
	}
	setClassByName(main.getCurrentProject().getSchemaProjet());
	dup = duplicate(type);
}
 
開發者ID:coco35700,項目名稱:uPMT,代碼行數:18,代碼來源:AddTypeCommand.java

示例5: handleDropped

import javafx.scene.input.DragEvent; //導入依賴的package包/類
@FXML
private void handleDropped(DragEvent event) {
    // ドラッグボードを取得
    Dragboard board = event.getDragboard();
    if (board.hasFiles()) {
        board.getFiles().stream().forEach((f) -> {
            if (f.isDirectory()) {
                List<String> filePathList = new ArrayList<>();
                getFileRecursion(filePathList, f.getAbsolutePath()).stream().filter(s -> isTextFile(s)).collect(Collectors.toList()).forEach(s -> fileList.getItems().add(new Label(s)));
            } else {
                if (isTextFile(f.getAbsolutePath()))
                    fileList.getItems().add(new Label(f.getAbsolutePath()));
            }
        });
        // ドロップ受け入れ
        event.setDropCompleted(true);
    } else {    // ファイル以外なら
        // ドロップ受け入れ拒否
        event.setDropCompleted(false);
    }
}
 
開發者ID:Khromium,項目名稱:MakeSourceList4j,代碼行數:22,代碼來源:Controller.java

示例6: targetSetOnDragDropped

import javafx.scene.input.DragEvent; //導入依賴的package包/類
private void targetSetOnDragDropped(ScreenMap target, DragEvent e) {
	Dragboard db = e.getDragboard();
	boolean success = false;
	if (e.getDragboard().hasImage()) {
		String imageName = db.getString();
		Point2D point = target.sceneToLocal(e.getSceneX(), e.getSceneY());
		GamePoint gameCoords = new GamePoint(point.getX()/target.getScreenWidth(), point.getY()/target.getScreenHeight());
		for (Pair<String, Image> p : myScreenObjects.keySet()) {
			String iName = p.getKey();
			if (imageName.equals(iName)) {
				XStreamHandler xstream = new XStreamHandler();
				File tempSpriteFile = new File("data/tempSprites/tempSprite.xml");
				xstream.saveToFile(myScreenObjects.get(p), tempSpriteFile);
				SpriteMakerModel xmlSprite = (SpriteMakerModel) xstream.getAttributeFromFile(tempSpriteFile);
				xmlSprite.addComponent(new Position(gameCoords, 0)); //heading 0 because all sprites default to this
				myModel.addBackgroundTile(xmlSprite);
				break;
			}
		}
		success = true;
	}
	e.setDropCompleted(success);
	e.consume();
}
 
開發者ID:LtubSalad,項目名稱:voogasalad-ltub,代碼行數:25,代碼來源:ScreenObjectHolder.java

示例7: dragDropped

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Handle dropped files to editor.
 */
@FXThread
private void dragDropped(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    handleFile(file);
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:19,代碼來源:ResourcePropertyEditorControl.java

示例8: dragOver

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Handle drag over.
 */
@FXThread
private void dragOver(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);
    if (!canAccept(file)) return;

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:23,代碼來源:ResourcePropertyEditorControl.java

示例9: handleDragDroppedEvent

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Handle dropped events.
 *
 * @param dragEvent the dropped event.
 */
@FXThread
private void handleDragDroppedEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    addMaterial(file.toPath());
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:24,代碼來源:MaterialPropertyControl.java

示例10: handleDragOverEvent

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Handle drag over events.
 *
 * @param dragEvent the drag over event.
 */
@FXThread
private void handleDragOverEvent(@NotNull final DragEvent dragEvent) {

    final Dragboard dragboard = dragEvent.getDragboard();
    final List<File> files = unsafeCast(dragboard.getContent(DataFormat.FILES));

    if (files == null || files.size() != 1) {
        return;
    }

    final File file = files.get(0);

    if (!file.getName().endsWith(FileExtensions.JME_MATERIAL)) {
        return;
    }

    final Set<TransferMode> transferModes = dragboard.getTransferModes();
    final boolean isCopy = transferModes.contains(TransferMode.COPY);

    dragEvent.acceptTransferModes(isCopy ? TransferMode.COPY : TransferMode.MOVE);
    dragEvent.consume();
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:28,代碼來源:MaterialPropertyControl.java

示例11: onDragDropped

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Drag dropped to the file drop area.
 *
 * @param event
 *            Event data.
 */
public final void onDragDropped(final DragEvent event) throws IOException {
    boolean success = false;
    LOG.log(Level.FINE, "Drag dropped: " + event.getDragboard().getString());
    if (event.getDragboard().hasFiles()) {
        File file = event.getDragboard().getFiles().get(0);
        // Check if file has a valid extension
        if (file.getName().endsWith(".bin")) {
            openSimulationFile(file);
            success = true;
        } else {
            String message = "Incorrect extension of the opened file (required .bin)";
            Dialog.createExceptionDialog(message, new IllegalArgumentException(message));
        }
    }
    event.setDropCompleted(success);
    event.consume();
}
 
開發者ID:gim-,項目名稱:particles-in-box-java,代碼行數:24,代碼來源:NewExperimentController.java

示例12: dragDropped

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Drag dropped action
 * 
 * @param event
 */
@FXML
public void dragDropped(DragEvent event) {		
   	try {
		loadConfig(event.getDragboard().getFiles().get(0));
	} catch (Exception e) {
		// TODO Auto-generated catch block
		Alert alert = new Alert(Alert.AlertType.ERROR);
		alert.setTitle("Import");
		alert.setHeaderText("Loading error");
		alert.setContentText(e.getMessage());
		alert.initModality(Modality.WINDOW_MODAL);
		alert.showAndWait();
		e.printStackTrace();
		return;
	}
      
	menuController.selectExerciseOverview();
   	event.setDropCompleted(true);
       event.consume();
}
 
開發者ID:ProPra16,項目名稱:programmierpraktikum-abschlussprojekt-null,代碼行數:26,代碼來源:ImportViewController.java

示例13: mouseDragOver

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Mouse dragover event.
 * 
 * @param event
 */
private void mouseDragOver (final DragEvent event) {
    if (event.getGestureSource() != contentPane &&
        (event.getDragboard().hasContent(VoogaFileFormat.getInstance()))) {
        VoogaFile content =
                (VoogaFile) event.getDragboard().getContent(VoogaFileFormat.getInstance());
        String color = "";
        if (content.getType() != VoogaFileType.FOLDER) {
            color = designboardProperties.getString("NonVoogaFileColor");
        }
        else {
            color = designboardProperties.getString("VoogaFileColor");
        }
        contentPane.setStyle(String
                .format(designboardProperties.getString("ContentPaneStringStyle"), color));
        event.acceptTransferModes(TransferMode.ANY);
    }
    else if (event.getDragboard().hasString()) {
        event.acceptTransferModes(TransferMode.ANY);
    }

    event.consume();
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:28,代碼來源:DesignBoard.java

示例14: addElement

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/**
 * Method to add new element to the design board
 * 
 * @param file: file to add
 * @param event: drag and drop feature
 * @param archetype: archetype (if element has one)
 */
private void addElement (VoogaFile file, DragEvent event, String archetype) {
    String elementPath = file.getPath();
    if (elementPath != null) {
        try {
            if (ResourceDecipherer.isImage(elementPath)) {

                GameObjectBuilder builder = new GameObjectBuilder(elementManager);
                if (!archetype.isEmpty()) {
                    builder.setArchetype(archetype);
                }
                else {
                    builder.setDraggedImage(file.getPath());
                }
                builder.showAndWait();

            }
        }
        catch (VoogaException e) {
            VoogaAlert alert = new VoogaAlert(e.getMessage());
            alert.showAndWait();
        }
        elementManager.addElementId(elementPath);
    }
}
 
開發者ID:sjain28,項目名稱:Game-Engine-Vooga,代碼行數:32,代碼來源:DesignBoard.java

示例15: onDagOver

import javafx.scene.input.DragEvent; //導入依賴的package包/類
/*********************************************************/
// 파일 드래그 드롭 처리.

/*
 * (non-Javadoc)
 * 
 * @see com.kyj.fx.voeditor.visual.component.text.AbstractDragDropHelper#
 * onDagOver(javafx.scene.input.DragEvent)
 */
@Override
public void onDagOver(DragEvent ev) {
	if (ev.isConsumed())
		return;

	if (ev.getDragboard().hasFiles()) {
		ev.acceptTransferModes(TransferMode.LINK);
		ev.consume();
	}

}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:21,代碼來源:CodeAreaFileDragDropHelper.java


注:本文中的javafx.scene.input.DragEvent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。